blob: 8264a8b29cae7e90614c440bac03cba5c62b4b7c [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//
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
17Macros:
18
19 offsetof(type,member-designator)
20 NULL
21
22namespace 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 Hinnante0569242010-05-28 18:04:31 +000037#define __need_NULL
Howard Hinnantadff4892010-05-24 17:49:41 +000038#define __need_ptrdiff_t
39#define __need_size_t
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000040#include <stddef.h>
Howard Hinnante0569242010-05-28 18:04:31 +000041#include <stddef.h>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000042
43#pragma GCC system_header
44
45_LIBCPP_BEGIN_NAMESPACE_STD
46
47using ::ptrdiff_t;
48using ::size_t;
49
50typedef long double max_align_t;
51
52#ifdef _LIBCPP_HAS_NO_NULLPTR
53
54struct nullptr_t
55{
56 void* _;
57
58 struct __nat {int __for_bool_;};
59
60 _LIBCPP_ALWAYS_INLINE nullptr_t(int __nat::*) {}
61
62 _LIBCPP_ALWAYS_INLINE operator int __nat::*() const {return 0;}
63
Howard Hinnantd8bc09b2010-05-18 17:32:30 +000064 template <class _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000065 _LIBCPP_ALWAYS_INLINE
Howard Hinnantd8bc09b2010-05-18 17:32:30 +000066 operator _Tp* () const {return 0;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000067
Howard Hinnantd8bc09b2010-05-18 17:32:30 +000068 template <class _Tp, class _Up>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000069 _LIBCPP_ALWAYS_INLINE
Howard Hinnantd8bc09b2010-05-18 17:32:30 +000070 operator _Tp _Up::* () const {return 0;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000071
72 friend _LIBCPP_ALWAYS_INLINE bool operator==(nullptr_t, nullptr_t) {return true;}
73 friend _LIBCPP_ALWAYS_INLINE bool operator!=(nullptr_t, nullptr_t) {return false;}
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 friend _LIBCPP_ALWAYS_INLINE bool operator>(nullptr_t, nullptr_t) {return false;}
77 friend _LIBCPP_ALWAYS_INLINE bool operator>=(nullptr_t, nullptr_t) {return true;}
78};
79
80inline _LIBCPP_ALWAYS_INLINE nullptr_t __get_nullptr_t() {return nullptr_t(0);}
81
82#define nullptr _STD::__get_nullptr_t()
83
84#else
85
86typedef decltype(nullptr) nullptr_t;
87
88#endif
89
90_LIBCPP_END_NAMESPACE_STD
91
92#endif // _LIBCPP_CSTDDEF