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 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 6 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 7 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 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 |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 21 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 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 | ed30e07 | 2010-06-02 18:53:22 +0000 | [diff] [blame] | 37 | |
| 38 | #ifdef __GLIBC__ |
| 39 | #define __need_NULL |
| 40 | #define __need_ptrdiff_t |
| 41 | #define __need_size_t |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 42 | #endif // __GLIBC__ |
Howard Hinnant | ed30e07 | 2010-06-02 18:53:22 +0000 | [diff] [blame] | 43 | |
Howard Hinnant | e056924 | 2010-05-28 18:04:31 +0000 | [diff] [blame] | 44 | #include <stddef.h> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 45 | |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 46 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 47 | #pragma GCC system_header |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 48 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 49 | |
| 50 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 51 | |
| 52 | using ::ptrdiff_t; |
| 53 | using ::size_t; |
| 54 | |
| 55 | typedef long double max_align_t; |
| 56 | |
| 57 | #ifdef _LIBCPP_HAS_NO_NULLPTR |
| 58 | |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 59 | struct _LIBCPP_TYPE_VIS_ONLY nullptr_t |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 60 | { |
Howard Hinnant | 9c0df14 | 2012-10-30 19:06:59 +0000 | [diff] [blame] | 61 | void* __lx; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 62 | |
| 63 | struct __nat {int __for_bool_;}; |
| 64 | |
Howard Hinnant | 9c0df14 | 2012-10-30 19:06:59 +0000 | [diff] [blame] | 65 | _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {} |
| 66 | _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 67 | |
Howard Hinnant | c25d158 | 2012-09-24 23:36:40 +0000 | [diff] [blame] | 68 | _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 69 | |
Howard Hinnant | d8bc09b | 2010-05-18 17:32:30 +0000 | [diff] [blame] | 70 | template <class _Tp> |
Howard Hinnant | c25d158 | 2012-09-24 23:36:40 +0000 | [diff] [blame] | 71 | _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR |
Howard Hinnant | d8bc09b | 2010-05-18 17:32:30 +0000 | [diff] [blame] | 72 | operator _Tp* () const {return 0;} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 73 | |
Howard Hinnant | d8bc09b | 2010-05-18 17:32:30 +0000 | [diff] [blame] | 74 | template <class _Tp, class _Up> |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 75 | _LIBCPP_ALWAYS_INLINE |
Howard Hinnant | d8bc09b | 2010-05-18 17:32:30 +0000 | [diff] [blame] | 76 | operator _Tp _Up::* () const {return 0;} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 77 | |
Howard Hinnant | c25d158 | 2012-09-24 23:36:40 +0000 | [diff] [blame] | 78 | friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;} |
| 79 | friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;} |
| 80 | friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<(nullptr_t, nullptr_t) {return false;} |
| 81 | friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<=(nullptr_t, nullptr_t) {return true;} |
| 82 | friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>(nullptr_t, nullptr_t) {return false;} |
| 83 | friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>=(nullptr_t, nullptr_t) {return true;} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 84 | }; |
| 85 | |
Howard Hinnant | c25d158 | 2012-09-24 23:36:40 +0000 | [diff] [blame] | 86 | inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 87 | |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 88 | #define nullptr _VSTD::__get_nullptr_t() |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 89 | |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 90 | #endif // _LIBCPP_HAS_NO_NULLPTR |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 91 | |
| 92 | _LIBCPP_END_NAMESPACE_STD |
| 93 | |
Howard Hinnant | c28dbee | 2011-06-05 13:00:46 +0000 | [diff] [blame] | 94 | #ifndef _LIBCPP_HAS_NO_NULLPTR |
| 95 | |
| 96 | namespace std |
| 97 | { |
| 98 | typedef decltype(nullptr) nullptr_t; |
| 99 | } |
| 100 | |
| 101 | #endif // _LIBCPP_HAS_NO_NULLPTR |
| 102 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 103 | #endif // _LIBCPP_CSTDDEF |