blob: b851ea00926362caadbd75da61f2bd747d07cdad [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:161// -*- C++ -*-
2//===--------------------------- cstddef ----------------------------------===//
3//
Howard Hinnant5b08a8a2010-05-11 21:36:014// The LLVM Compiler Infrastructure
Howard Hinnant3e519522010-05-11 19:42:165//
Howard Hinnant412dbeb2010-11-16 22:09:026// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Howard Hinnant3e519522010-05-11 19:42:168//
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 Hinnantb3371f62010-08-22 00:02:4321
Howard Hinnant3e519522010-05-11 19:42:1622namespace 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 Hinnant8ae50972010-06-02 18:53:2237
38#ifdef __GLIBC__
39#define __need_NULL
40#define __need_ptrdiff_t
41#define __need_size_t
Howard Hinnantb3371f62010-08-22 00:02:4342#endif // __GLIBC__
Howard Hinnant8ae50972010-06-02 18:53:2243
Howard Hinnantbc3c5dc2010-05-28 18:04:3144#include <stddef.h>
Howard Hinnant3e519522010-05-11 19:42:1645
46#pragma GCC system_header
47
48_LIBCPP_BEGIN_NAMESPACE_STD
49
50using ::ptrdiff_t;
51using ::size_t;
52
53typedef long double max_align_t;
54
55#ifdef _LIBCPP_HAS_NO_NULLPTR
56
Howard Hinnantfb100022010-09-21 21:28:2357struct _LIBCPP_VISIBLE nullptr_t
Howard Hinnant3e519522010-05-11 19:42:1658{
59 void* _;
60
61 struct __nat {int __for_bool_;};
62
63 _LIBCPP_ALWAYS_INLINE nullptr_t(int __nat::*) {}
64
65 _LIBCPP_ALWAYS_INLINE operator int __nat::*() const {return 0;}
66
Howard Hinnante31e36f2010-05-18 17:32:3067 template <class _Tp>
Howard Hinnantb3371f62010-08-22 00:02:4368 _LIBCPP_ALWAYS_INLINE
Howard Hinnante31e36f2010-05-18 17:32:3069 operator _Tp* () const {return 0;}
Howard Hinnant3e519522010-05-11 19:42:1670
Howard Hinnante31e36f2010-05-18 17:32:3071 template <class _Tp, class _Up>
Howard Hinnantb3371f62010-08-22 00:02:4372 _LIBCPP_ALWAYS_INLINE
Howard Hinnante31e36f2010-05-18 17:32:3073 operator _Tp _Up::* () const {return 0;}
Howard Hinnant3e519522010-05-11 19:42:1674
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 false;}
78 friend _LIBCPP_ALWAYS_INLINE bool operator<=(nullptr_t, nullptr_t) {return true;}
79 friend _LIBCPP_ALWAYS_INLINE bool operator>(nullptr_t, nullptr_t) {return false;}
80 friend _LIBCPP_ALWAYS_INLINE bool operator>=(nullptr_t, nullptr_t) {return true;}
Howard Hinnant3e519522010-05-11 19:42:1681};
82
83inline _LIBCPP_ALWAYS_INLINE nullptr_t __get_nullptr_t() {return nullptr_t(0);}
84
Howard Hinnantce48a112011-06-30 21:18:1985#define nullptr _VSTD::__get_nullptr_t()
Howard Hinnant3e519522010-05-11 19:42:1686
Howard Hinnantb3371f62010-08-22 00:02:4387#endif // _LIBCPP_HAS_NO_NULLPTR
Howard Hinnant3e519522010-05-11 19:42:1688
89_LIBCPP_END_NAMESPACE_STD
90
Howard Hinnant32208bd2011-06-05 13:00:4691#ifndef _LIBCPP_HAS_NO_NULLPTR
92
93namespace std
94{
95 typedef decltype(nullptr) nullptr_t;
96}
97
98#endif // _LIBCPP_HAS_NO_NULLPTR
99
Howard Hinnant3e519522010-05-11 19:42:16100#endif // _LIBCPP_CSTDDEF