blob: c939f0ea9154c9b6f495431a8c05be33be617863 [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
60 template <class T>
61 _LIBCPP_ALWAYS_INLINE
62 operator T* () const {return 0;}
63
64 template <class T, class U>
65 _LIBCPP_ALWAYS_INLINE
66 operator T U::* () const {return 0;}
67
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