Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- cstddef ----------------------------------===// |
| 3 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 4 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 5 | // |
| 6 | // This file is distributed under the University of Illinois Open Source |
| 7 | // License. See LICENSE.TXT for details. |
| 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | |
| 11 | #ifndef _LIBCPP_CSTDDEF |
| 12 | #define _LIBCPP_CSTDDEF |
| 13 | |
| 14 | /* |
| 15 | cstddef synopsis |
| 16 | |
| 17 | Macros: |
| 18 | |
| 19 | offsetof(type,member-designator) |
| 20 | NULL |
| 21 | |
| 22 | namespace std |
| 23 | { |
| 24 | |
| 25 | Types: |
| 26 | |
| 27 | ptrdiff_t |
| 28 | size_t |
| 29 | max_align_t |
| 30 | nullptr_t |
| 31 | |
| 32 | } // std |
| 33 | |
| 34 | */ |
| 35 | |
| 36 | #include <__config> |
Howard Hinnant | adff489 | 2010-05-24 17:49:41 +0000 | [diff] [blame] | 37 | #define __need_ptrdiff_t |
| 38 | #define __need_size_t |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 39 | #include <stddef.h> |
| 40 | |
| 41 | #pragma GCC system_header |
| 42 | |
| 43 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 44 | |
| 45 | using ::ptrdiff_t; |
| 46 | using ::size_t; |
| 47 | |
| 48 | typedef long double max_align_t; |
| 49 | |
| 50 | #ifdef _LIBCPP_HAS_NO_NULLPTR |
| 51 | |
| 52 | struct nullptr_t |
| 53 | { |
| 54 | void* _; |
| 55 | |
| 56 | struct __nat {int __for_bool_;}; |
| 57 | |
| 58 | _LIBCPP_ALWAYS_INLINE nullptr_t(int __nat::*) {} |
| 59 | |
| 60 | _LIBCPP_ALWAYS_INLINE operator int __nat::*() const {return 0;} |
| 61 | |
Howard Hinnant | d8bc09b | 2010-05-18 17:32:30 +0000 | [diff] [blame] | 62 | template <class _Tp> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 63 | _LIBCPP_ALWAYS_INLINE |
Howard Hinnant | d8bc09b | 2010-05-18 17:32:30 +0000 | [diff] [blame] | 64 | operator _Tp* () const {return 0;} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 65 | |
Howard Hinnant | d8bc09b | 2010-05-18 17:32:30 +0000 | [diff] [blame] | 66 | template <class _Tp, class _Up> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 67 | _LIBCPP_ALWAYS_INLINE |
Howard Hinnant | d8bc09b | 2010-05-18 17:32:30 +0000 | [diff] [blame] | 68 | operator _Tp _Up::* () const {return 0;} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 69 | |
| 70 | friend _LIBCPP_ALWAYS_INLINE bool operator==(nullptr_t, nullptr_t) {return true;} |
| 71 | friend _LIBCPP_ALWAYS_INLINE bool operator!=(nullptr_t, nullptr_t) {return false;} |
| 72 | friend _LIBCPP_ALWAYS_INLINE bool operator<(nullptr_t, nullptr_t) {return false;} |
| 73 | friend _LIBCPP_ALWAYS_INLINE bool operator<=(nullptr_t, nullptr_t) {return true;} |
| 74 | friend _LIBCPP_ALWAYS_INLINE bool operator>(nullptr_t, nullptr_t) {return false;} |
| 75 | friend _LIBCPP_ALWAYS_INLINE bool operator>=(nullptr_t, nullptr_t) {return true;} |
| 76 | }; |
| 77 | |
| 78 | inline _LIBCPP_ALWAYS_INLINE nullptr_t __get_nullptr_t() {return nullptr_t(0);} |
| 79 | |
| 80 | #define nullptr _STD::__get_nullptr_t() |
| 81 | |
| 82 | #else |
| 83 | |
| 84 | typedef decltype(nullptr) nullptr_t; |
| 85 | |
| 86 | #endif |
| 87 | |
| 88 | _LIBCPP_END_NAMESPACE_STD |
| 89 | |
| 90 | #endif // _LIBCPP_CSTDDEF |