blob: 11d07a2ec2927cb169fc667a86debc2252ed9a7f [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>
37#include <stddef.h>
38
39#pragma GCC system_header
40
41_LIBCPP_BEGIN_NAMESPACE_STD
42
43using ::ptrdiff_t;
44using ::size_t;
45
46typedef long double max_align_t;
47
48#ifdef _LIBCPP_HAS_NO_NULLPTR
49
50struct nullptr_t
51{
52 void* _;
53
54 struct __nat {int __for_bool_;};
55
56 _LIBCPP_ALWAYS_INLINE nullptr_t(int __nat::*) {}
57
58 _LIBCPP_ALWAYS_INLINE operator int __nat::*() const {return 0;}
59
Howard Hinnantd8bc09b2010-05-18 17:32:30 +000060 template <class _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000061 _LIBCPP_ALWAYS_INLINE
Howard Hinnantd8bc09b2010-05-18 17:32:30 +000062 operator _Tp* () const {return 0;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000063
Howard Hinnantd8bc09b2010-05-18 17:32:30 +000064 template <class _Tp, class _Up>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000065 _LIBCPP_ALWAYS_INLINE
Howard Hinnantd8bc09b2010-05-18 17:32:30 +000066 operator _Tp _Up::* () const {return 0;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000067
68 friend _LIBCPP_ALWAYS_INLINE bool operator==(nullptr_t, nullptr_t) {return true;}
69 friend _LIBCPP_ALWAYS_INLINE bool operator!=(nullptr_t, nullptr_t) {return false;}
70 friend _LIBCPP_ALWAYS_INLINE bool operator<(nullptr_t, nullptr_t) {return false;}
71 friend _LIBCPP_ALWAYS_INLINE bool operator<=(nullptr_t, nullptr_t) {return true;}
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};
75
76inline _LIBCPP_ALWAYS_INLINE nullptr_t __get_nullptr_t() {return nullptr_t(0);}
77
78#define nullptr _STD::__get_nullptr_t()
79
80#else
81
82typedef decltype(nullptr) nullptr_t;
83
84#endif
85
86_LIBCPP_END_NAMESPACE_STD
87
88#endif // _LIBCPP_CSTDDEF