xref: /aosp_15_r20/external/libcxx/include/__nullptr (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*-
2*58b9f456SAndroid Build Coastguard Worker//===--------------------------- __nullptr --------------------------------===//
3*58b9f456SAndroid Build Coastguard Worker//
4*58b9f456SAndroid Build Coastguard Worker//                     The LLVM Compiler Infrastructure
5*58b9f456SAndroid Build Coastguard Worker//
6*58b9f456SAndroid Build Coastguard Worker// This file is dual licensed under the MIT and the University of Illinois Open
7*58b9f456SAndroid Build Coastguard Worker// Source Licenses. See LICENSE.TXT for details.
8*58b9f456SAndroid Build Coastguard Worker//
9*58b9f456SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
10*58b9f456SAndroid Build Coastguard Worker
11*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NULLPTR
12*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_NULLPTR
13*58b9f456SAndroid Build Coastguard Worker
14*58b9f456SAndroid Build Coastguard Worker#include <__config>
15*58b9f456SAndroid Build Coastguard Worker
16*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header
18*58b9f456SAndroid Build Coastguard Worker#endif
19*58b9f456SAndroid Build Coastguard Worker
20*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_HAS_NO_NULLPTR
21*58b9f456SAndroid Build Coastguard Worker
22*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_STD
23*58b9f456SAndroid Build Coastguard Worker
24*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS nullptr_t
25*58b9f456SAndroid Build Coastguard Worker{
26*58b9f456SAndroid Build Coastguard Worker    void* __lx;
27*58b9f456SAndroid Build Coastguard Worker
28*58b9f456SAndroid Build Coastguard Worker    struct __nat {int __for_bool_;};
29*58b9f456SAndroid Build Coastguard Worker
30*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {}
31*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {}
32*58b9f456SAndroid Build Coastguard Worker
33*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;}
34*58b9f456SAndroid Build Coastguard Worker
35*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
36*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
37*58b9f456SAndroid Build Coastguard Worker        operator _Tp* () const {return 0;}
38*58b9f456SAndroid Build Coastguard Worker
39*58b9f456SAndroid Build Coastguard Worker    template <class _Tp, class _Up>
40*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
41*58b9f456SAndroid Build Coastguard Worker        operator _Tp _Up::* () const {return 0;}
42*58b9f456SAndroid Build Coastguard Worker
43*58b9f456SAndroid Build Coastguard Worker    friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;}
44*58b9f456SAndroid Build Coastguard Worker    friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;}
45*58b9f456SAndroid Build Coastguard Worker};
46*58b9f456SAndroid Build Coastguard Worker
47*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);}
48*58b9f456SAndroid Build Coastguard Worker
49*58b9f456SAndroid Build Coastguard Worker#define nullptr _VSTD::__get_nullptr_t()
50*58b9f456SAndroid Build Coastguard Worker
51*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_STD
52*58b9f456SAndroid Build Coastguard Worker
53*58b9f456SAndroid Build Coastguard Worker#else  // _LIBCPP_HAS_NO_NULLPTR
54*58b9f456SAndroid Build Coastguard Worker
55*58b9f456SAndroid Build Coastguard Workernamespace std
56*58b9f456SAndroid Build Coastguard Worker{
57*58b9f456SAndroid Build Coastguard Worker    typedef decltype(nullptr) nullptr_t;
58*58b9f456SAndroid Build Coastguard Worker}
59*58b9f456SAndroid Build Coastguard Worker
60*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_HAS_NO_NULLPTR
61*58b9f456SAndroid Build Coastguard Worker
62*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NULLPTR
63