blob: 7ef16ff2a367ccbca9579bc26a6e5ae6dd169956 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001// -*- C++ -*-
2//===--------------------------- cstddef ----------------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00005//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00006// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00008//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_CSTDDEF
12#define _LIBCPP_CSTDDEF
13
14/*
15 cstddef synopsis
16
17Macros:
18
19 offsetof(type,member-designator)
20 NULL
Howard Hinnant324bb032010-08-22 00:02:43 +000021
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000022namespace std
23{
24
25Types:
26
27 ptrdiff_t
28 size_t
29 max_align_t
30 nullptr_t
31
32} // std
33
34*/
35
36#include <__config>
Howard Hinnanted30e072010-06-02 18:53:22 +000037
38#ifdef __GLIBC__
39#define __need_NULL
40#define __need_ptrdiff_t
41#define __need_size_t
Howard Hinnant324bb032010-08-22 00:02:43 +000042#endif // __GLIBC__
Howard Hinnanted30e072010-06-02 18:53:22 +000043
Howard Hinnante0569242010-05-28 18:04:31 +000044#include <stddef.h>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000045
Howard Hinnant08e17472011-10-17 20:05:10 +000046#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000047#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10 +000048#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000049
50_LIBCPP_BEGIN_NAMESPACE_STD
51
52using ::ptrdiff_t;
53using ::size_t;
54
55typedef long double max_align_t;
56
57#ifdef _LIBCPP_HAS_NO_NULLPTR
58
Howard Hinnant0f678bd2013-08-12 18:38:34 +000059struct _LIBCPP_TYPE_VIS_ONLY nullptr_t
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000060{
Howard Hinnant9c0df142012-10-30 19:06:59 +000061 void* __lx;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000062
63 struct __nat {int __for_bool_;};
64
Howard Hinnant9c0df142012-10-30 19:06:59 +000065 _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {}
66 _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000067
Howard Hinnantc25d1582012-09-24 23:36:40 +000068 _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000069
Howard Hinnantd8bc09b2010-05-18 17:32:30 +000070 template <class _Tp>
Howard Hinnantc25d1582012-09-24 23:36:40 +000071 _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR
Howard Hinnantd8bc09b2010-05-18 17:32:30 +000072 operator _Tp* () const {return 0;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000073
Howard Hinnantd8bc09b2010-05-18 17:32:30 +000074 template <class _Tp, class _Up>
Howard Hinnant324bb032010-08-22 00:02:43 +000075 _LIBCPP_ALWAYS_INLINE
Howard Hinnantd8bc09b2010-05-18 17:32:30 +000076 operator _Tp _Up::* () const {return 0;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000077
Howard Hinnantc25d1582012-09-24 23:36:40 +000078 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 Hinnantbc8d3f92010-05-11 19:42:16 +000084};
85
Howard Hinnantc25d1582012-09-24 23:36:40 +000086inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000087
Howard Hinnant0949eed2011-06-30 21:18:19 +000088#define nullptr _VSTD::__get_nullptr_t()
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000089
Howard Hinnant324bb032010-08-22 00:02:43 +000090#endif // _LIBCPP_HAS_NO_NULLPTR
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000091
92_LIBCPP_END_NAMESPACE_STD
93
Howard Hinnantc28dbee2011-06-05 13:00:46 +000094#ifndef _LIBCPP_HAS_NO_NULLPTR
95
96namespace std
97{
98 typedef decltype(nullptr) nullptr_t;
99}
100
101#endif // _LIBCPP_HAS_NO_NULLPTR
102
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000103#endif // _LIBCPP_CSTDDEF