OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef BASE_NULLPTR_H_ |
| 6 #define BASE_NULLPTR_H_ |
| 7 |
| 8 #include "base/base_export.h" |
| 9 #include "build/build_config.h" |
| 10 |
| 11 #if defined(NULLPTR_IS_NATIVE_TYPE) |
| 12 #include <cstddef> |
| 13 #endif |
| 14 |
| 15 namespace base { |
| 16 |
| 17 #if defined(NULLPTR_IS_NATIVE_TYPE) |
| 18 using std::nullptr_t; |
| 19 #elif defined(__GLIBCXX__) && __GLIBCXX__ < 20110325 |
| 20 typedef decltype(nullptr) nullptr_t; |
| 21 #else |
| 22 class BASE_EXPORT nullptr_t { |
| 23 public: |
| 24 template <class T> operator T*() const { return NULL; } |
| 25 template <class C, class T> operator T C::*() const { return NULL; } |
| 26 |
| 27 private: |
| 28 void operator&() const; |
| 29 }; |
| 30 #endif |
| 31 |
| 32 // Ideally, it would be possible to use base::nullptr across all platforms. |
| 33 // However, nullptr is implemented as a reserved keyword in C++11, and thus, |
| 34 // like "true" and "false", cannot be used as a name for a type. |
| 35 extern BASE_EXPORT nullptr_t NullPtr; |
| 36 |
| 37 } // namespace base |
| 38 |
| 39 #endif // #define BASE_NULLPTR_H_ |
OLD | NEW |