blob: 62584494d97c5a8c1d86e5a783b8966e53bb5abe [file] [log] [blame]
Howard Hinnantc51e1022010-05-11 19:42:16 +00001// -*- C++ -*-
2//===--------------------------- cstddef ----------------------------------===//
3//
Howard Hinnantc566dc32010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnantc51e1022010-05-11 19:42:16 +00005//
Howard Hinnantee11c312010-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 Hinnantc51e1022010-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 Hinnant3b6579a2010-08-22 00:02:43 +000021
Howard Hinnantc51e1022010-05-11 19:42:16 +000022namespace std
23{
24
25Types:
26
27 ptrdiff_t
28 size_t
29 max_align_t
30 nullptr_t
Marshall Clowcade1f72017-03-24 05:45:39 +000031 byte // C++17
Howard Hinnantc51e1022010-05-11 19:42:16 +000032
33} // std
34
35*/
36
37#include <__config>
Howard Hinnant59ef87b2010-06-02 18:53:22 +000038
Howard Hinnantaaaa52b2011-10-17 20:05:10 +000039#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantc51e1022010-05-11 19:42:16 +000040#pragma GCC system_header
Howard Hinnantaaaa52b2011-10-17 20:05:10 +000041#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +000042
Richard Smith523b1722015-10-09 00:26:50 +000043// Don't include our own <stddef.h>; we don't want to declare ::nullptr_t.
44#include_next <stddef.h>
45#include <__nullptr>
46
Howard Hinnantc51e1022010-05-11 19:42:16 +000047_LIBCPP_BEGIN_NAMESPACE_STD
48
49using ::ptrdiff_t;
50using ::size_t;
51
David L. Jones8465cf12017-02-10 01:27:42 +000052#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \
53 defined(__DEFINED_max_align_t)
Chandler Carruth4dcf1992014-02-21 08:37:30 +000054// Re-use the compiler's <stddef.h> max_align_t where possible.
55using ::max_align_t;
56#else
Howard Hinnantc51e1022010-05-11 19:42:16 +000057typedef long double max_align_t;
Chandler Carruth4dcf1992014-02-21 08:37:30 +000058#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +000059
Howard Hinnantc51e1022010-05-11 19:42:16 +000060_LIBCPP_END_NAMESPACE_STD
61
Marshall Clowcade1f72017-03-24 05:45:39 +000062#if _LIBCPP_STD_VER > 14
63namespace std // purposefully not versioned
64{
65enum class byte : unsigned char {};
66
67constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept
68{ return __lhs = byte(static_cast<unsigned char>(__lhs) | static_cast<unsigned char>(__rhs)); }
69constexpr byte operator| (byte __lhs, byte __rhs) noexcept
70{ return byte(static_cast<unsigned char>(__lhs) | static_cast<unsigned char>(__rhs)); }
71
72constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept
73{ return __lhs = byte(static_cast<unsigned char>(__lhs) & static_cast<unsigned char>(__rhs)); }
74constexpr byte operator& (byte __lhs, byte __rhs) noexcept
75{ return byte(static_cast<unsigned char>(__lhs) & static_cast<unsigned char>(__rhs)); }
76
77constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept
78{ return __lhs = byte(static_cast<unsigned char>(__lhs) ^ static_cast<unsigned char>(__rhs)); }
79constexpr byte operator^ (byte __lhs, byte __rhs) noexcept
80{ return byte(static_cast<unsigned char>(__lhs) ^ static_cast<unsigned char>(__rhs)); }
81
82constexpr byte operator~ (byte __b) noexcept
83{ return byte(~static_cast<unsigned char>(__b)); }
84
85}
86
87#include <type_traits> // rest of byte
88#endif
89
Howard Hinnantc51e1022010-05-11 19:42:16 +000090#endif // _LIBCPP_CSTDDEF