1 | // -*- C++ -*- |
2 | //===--------------------------- __nullptr --------------------------------===// |
3 | // |
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 |
7 | // |
8 | //===----------------------------------------------------------------------===// |
9 | |
10 | #ifndef _LIBCPP_NULLPTR |
11 | #define _LIBCPP_NULLPTR |
12 | |
13 | #include <__config> |
14 | |
15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
16 | #pragma GCC system_header |
17 | #endif |
18 | |
19 | #ifdef _LIBCPP_HAS_NO_NULLPTR |
20 | |
21 | _LIBCPP_BEGIN_NAMESPACE_STD |
22 | |
23 | struct _LIBCPP_TEMPLATE_VIS nullptr_t |
24 | { |
25 | void* __lx; |
26 | |
27 | struct __nat {int __for_bool_;}; |
28 | |
29 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {} |
30 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {} |
31 | |
32 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;} |
33 | |
34 | template <class _Tp> |
35 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
36 | operator _Tp* () const {return 0;} |
37 | |
38 | template <class _Tp, class _Up> |
39 | _LIBCPP_INLINE_VISIBILITY |
40 | operator _Tp _Up::* () const {return 0;} |
41 | |
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;} |
44 | }; |
45 | |
46 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);} |
47 | |
48 | #define nullptr _VSTD::__get_nullptr_t() |
49 | |
50 | _LIBCPP_END_NAMESPACE_STD |
51 | |
52 | #else // _LIBCPP_HAS_NO_NULLPTR |
53 | |
54 | namespace std |
55 | { |
56 | typedef decltype(nullptr) nullptr_t; |
57 | } |
58 | |
59 | #endif // _LIBCPP_HAS_NO_NULLPTR |
60 | |
61 | #endif // _LIBCPP_NULLPTR |
62 | |