Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2661)

Unified Diff: base/nullptr.h

Issue 11411318: DO NOT COMMIT: NullPtr support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: WIP Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/memory/scoped_ptr.h ('k') | base/nullptr.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/nullptr.h
diff --git a/base/nullptr.h b/base/nullptr.h
new file mode 100644
index 0000000000000000000000000000000000000000..4d563a5382d505a3dee4b303aa3b2f3eda6f7f70
--- /dev/null
+++ b/base/nullptr.h
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_NULLPTR_H_
+#define BASE_NULLPTR_H_
+
+#include "base/base_export.h"
+#include "build/build_config.h"
+
+#if defined(NULLPTR_IS_NATIVE_TYPE)
+#include <cstddef>
+#endif
+
+namespace base {
+
+#if defined(NULLPTR_IS_NATIVE_TYPE)
+using std::nullptr_t;
+#elif defined(__GLIBCXX__) && __GLIBCXX__ < 20110325
+typedef decltype(nullptr) nullptr_t;
+#else
+class BASE_EXPORT nullptr_t {
+ public:
+ template <class T> operator T*() const { return NULL; }
+ template <class C, class T> operator T C::*() const { return NULL; }
+
+ private:
+ void operator&() const;
+};
+#endif
+
+// Ideally, it would be possible to use base::nullptr across all platforms.
+// However, nullptr is implemented as a reserved keyword in C++11, and thus,
+// like "true" and "false", cannot be used as a name for a type.
+extern BASE_EXPORT nullptr_t NullPtr;
+
+} // namespace base
+
+#endif // #define BASE_NULLPTR_H_
« no previous file with comments | « base/memory/scoped_ptr.h ('k') | base/nullptr.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698