cstddef 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // -*- C++ -*-
  2. //===--------------------------- cstddef ----------------------------------===//
  3. //
  4. // The LLVM Compiler Infrastructure
  5. //
  6. // This file is dual licensed under the MIT and the University of Illinois Open
  7. // Source Licenses. See LICENSE.TXT for details.
  8. //
  9. //===----------------------------------------------------------------------===//
  10. #ifndef _LIBCPP_CSTDDEF
  11. #define _LIBCPP_CSTDDEF
  12. /*
  13. cstddef synopsis
  14. Macros:
  15. offsetof(type,member-designator)
  16. NULL
  17. namespace std
  18. {
  19. Types:
  20. ptrdiff_t
  21. size_t
  22. max_align_t
  23. nullptr_t
  24. } // std
  25. */
  26. #include <__config>
  27. #include <stddef.h>
  28. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  29. #pragma GCC system_header
  30. #endif
  31. _LIBCPP_BEGIN_NAMESPACE_STD
  32. using ::ptrdiff_t;
  33. using ::size_t;
  34. #if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T)
  35. // Re-use the compiler's <stddef.h> max_align_t where possible.
  36. using ::max_align_t;
  37. #else
  38. typedef long double max_align_t;
  39. #endif
  40. #ifdef _LIBCPP_HAS_NO_NULLPTR
  41. struct _LIBCPP_TYPE_VIS_ONLY nullptr_t
  42. {
  43. void* __lx;
  44. struct __nat {int __for_bool_;};
  45. _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {}
  46. _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {}
  47. _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;}
  48. template <class _Tp>
  49. _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR
  50. operator _Tp* () const {return 0;}
  51. template <class _Tp, class _Up>
  52. _LIBCPP_ALWAYS_INLINE
  53. operator _Tp _Up::* () const {return 0;}
  54. friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;}
  55. friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;}
  56. friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<(nullptr_t, nullptr_t) {return false;}
  57. friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<=(nullptr_t, nullptr_t) {return true;}
  58. friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>(nullptr_t, nullptr_t) {return false;}
  59. friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>=(nullptr_t, nullptr_t) {return true;}
  60. };
  61. inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);}
  62. #define nullptr _VSTD::__get_nullptr_t()
  63. #endif // _LIBCPP_HAS_NO_NULLPTR
  64. _LIBCPP_END_NAMESPACE_STD
  65. #ifndef _LIBCPP_HAS_NO_NULLPTR
  66. namespace std
  67. {
  68. typedef decltype(nullptr) nullptr_t;
  69. }
  70. #endif // _LIBCPP_HAS_NO_NULLPTR
  71. #endif // _LIBCPP_CSTDDEF