19729cf09SDimitry Andric// -*- C++ -*- 29729cf09SDimitry Andric//===--------------------------- __nullptr --------------------------------===// 39729cf09SDimitry Andric// 49729cf09SDimitry Andric// The LLVM Compiler Infrastructure 59729cf09SDimitry Andric// 69729cf09SDimitry Andric// This file is dual licensed under the MIT and the University of Illinois Open 79729cf09SDimitry Andric// Source Licenses. See LICENSE.TXT for details. 89729cf09SDimitry Andric// 99729cf09SDimitry Andric//===----------------------------------------------------------------------===// 109729cf09SDimitry Andric 119729cf09SDimitry Andric#ifndef _LIBCPP_NULLPTR 129729cf09SDimitry Andric#define _LIBCPP_NULLPTR 139729cf09SDimitry Andric 149729cf09SDimitry Andric#include <__config> 159729cf09SDimitry Andric 169729cf09SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 179729cf09SDimitry Andric#pragma GCC system_header 189729cf09SDimitry Andric#endif 199729cf09SDimitry Andric 209729cf09SDimitry Andric#ifdef _LIBCPP_HAS_NO_NULLPTR 219729cf09SDimitry Andric 229729cf09SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 239729cf09SDimitry Andric 24aed8d94eSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS nullptr_t 259729cf09SDimitry Andric{ 269729cf09SDimitry Andric void* __lx; 279729cf09SDimitry Andric 289729cf09SDimitry Andric struct __nat {int __for_bool_;}; 299729cf09SDimitry Andric 30*4ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {} 31*4ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {} 329729cf09SDimitry Andric 33*4ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;} 349729cf09SDimitry Andric 359729cf09SDimitry Andric template <class _Tp> 36*4ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 379729cf09SDimitry Andric operator _Tp* () const {return 0;} 389729cf09SDimitry Andric 399729cf09SDimitry Andric template <class _Tp, class _Up> 40*4ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 419729cf09SDimitry Andric operator _Tp _Up::* () const {return 0;} 429729cf09SDimitry Andric 43*4ba319b5SDimitry Andric friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;} 44*4ba319b5SDimitry Andric friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;} 459729cf09SDimitry Andric}; 469729cf09SDimitry Andric 47*4ba319b5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);} 489729cf09SDimitry Andric 499729cf09SDimitry Andric#define nullptr _VSTD::__get_nullptr_t() 509729cf09SDimitry Andric 519729cf09SDimitry Andric_LIBCPP_END_NAMESPACE_STD 529729cf09SDimitry Andric 539729cf09SDimitry Andric#else // _LIBCPP_HAS_NO_NULLPTR 549729cf09SDimitry Andric 559729cf09SDimitry Andricnamespace std 569729cf09SDimitry Andric{ 579729cf09SDimitry Andric typedef decltype(nullptr) nullptr_t; 589729cf09SDimitry Andric} 599729cf09SDimitry Andric 609729cf09SDimitry Andric#endif // _LIBCPP_HAS_NO_NULLPTR 619729cf09SDimitry Andric 629729cf09SDimitry Andric#endif // _LIBCPP_NULLPTR 63