2 //===--------------------------- __nullptr --------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP_NULLPTR
11 #define _LIBCPP_NULLPTR
15 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16 #pragma GCC system_header
19 #ifdef _LIBCPP_HAS_NO_NULLPTR
21 _LIBCPP_BEGIN_NAMESPACE_STD
23 struct _LIBCPP_TEMPLATE_VIS nullptr_t
27 struct __nat {int __for_bool_;};
29 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {}
30 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {}
32 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;}
35 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
36 operator _Tp* () const {return 0;}
38 template <class _Tp, class _Up>
39 _LIBCPP_INLINE_VISIBILITY
40 operator _Tp _Up::* () const {return 0;}
42 friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;}
43 friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;}
46 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);}
48 #define nullptr _VSTD::__get_nullptr_t()
50 _LIBCPP_END_NAMESPACE_STD
52 #else // _LIBCPP_HAS_NO_NULLPTR
56 typedef decltype(nullptr) nullptr_t;
59 #endif // _LIBCPP_HAS_NO_NULLPTR
61 #endif // _LIBCPP_NULLPTR