blob: adeefdac9be6904b0df932e658fb9c57aa201673 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:161// -*- C++ -*-
2//===--------------------------- cstddef ----------------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:014// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:165//
Howard Hinnantb64f8b02010-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 Hinnantbc8d3f92010-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 Hinnant324bb032010-08-22 00:02:4321
Howard Hinnantbc8d3f92010-05-11 19:42:1622namespace std
23{
24
25Types:
26
27 ptrdiff_t
28 size_t
29 max_align_t
30 nullptr_t
Marshall Clow21ae16e2017-03-24 05:45:3931 byte // C++17
Howard Hinnantbc8d3f92010-05-11 19:42:1632
33} // std
34
35*/
36
37#include <__config>
Howard Hinnanted30e072010-06-02 18:53:2238
Howard Hinnant08e17472011-10-17 20:05:1039#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:1640#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:1041#endif
Howard Hinnantbc8d3f92010-05-11 19:42:1642
Richard Smith45bae0b2015-10-09 00:26:5043// 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 Hinnantbc8d3f92010-05-11 19:42:1647_LIBCPP_BEGIN_NAMESPACE_STD
48
49using ::ptrdiff_t;
50using ::size_t;
51
David L. Jones917331c2017-02-10 01:27:4252#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \
53 defined(__DEFINED_max_align_t)
Chandler Carruthf84f6112014-02-21 08:37:3054// Re-use the compiler's <stddef.h> max_align_t where possible.
55using ::max_align_t;
56#else
Howard Hinnantbc8d3f92010-05-11 19:42:1657typedef long double max_align_t;
Chandler Carruthf84f6112014-02-21 08:37:3058#endif
Howard Hinnantbc8d3f92010-05-11 19:42:1659
Howard Hinnantbc8d3f92010-05-11 19:42:1660_LIBCPP_END_NAMESPACE_STD
61
Marshall Clow21ae16e2017-03-24 05:45:3962#if _LIBCPP_STD_VER > 14
63namespace std // purposefully not versioned
64{
65enum class byte : unsigned char {};
66
Marshall Clow21ae16e2017-03-24 05:45:3967constexpr byte operator| (byte __lhs, byte __rhs) noexcept
Marshall Clow52728772017-11-14 01:14:5368{
69return static_cast<byte>(
70 static_cast<unsigned char>(
71 static_cast<unsigned int>(__lhs) | static_cast<unsigned int>(__rhs)
72));
73}
74
75constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept
76{ return __lhs = __lhs | __rhs; }
77
78constexpr byte operator& (byte __lhs, byte __rhs) noexcept
79{
80return static_cast<byte>(
81 static_cast<unsigned char>(
82 static_cast<unsigned int>(__lhs) & static_cast<unsigned int>(__rhs)
83));
84}
Marshall Clow21ae16e2017-03-24 05:45:3985
86constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept
Marshall Clow52728772017-11-14 01:14:5387{ return __lhs = __lhs & __rhs; }
88
89constexpr byte operator^ (byte __lhs, byte __rhs) noexcept
90{
91return static_cast<byte>(
92 static_cast<unsigned char>(
93 static_cast<unsigned int>(__lhs) ^ static_cast<unsigned int>(__rhs)
94));
95}
Marshall Clow21ae16e2017-03-24 05:45:3996
97constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept
Marshall Clow52728772017-11-14 01:14:5398{ return __lhs = __lhs ^ __rhs; }
Marshall Clow21ae16e2017-03-24 05:45:3999
100constexpr byte operator~ (byte __b) noexcept
Marshall Clow52728772017-11-14 01:14:53101{
102 return static_cast<byte>(
103 static_cast<unsigned char>(
104 ~static_cast<unsigned int>(__b)
105 ));
106}
Marshall Clow21ae16e2017-03-24 05:45:39107
108}
109
110#include <type_traits> // rest of byte
111#endif
112
Howard Hinnantbc8d3f92010-05-11 19:42:16113#endif // _LIBCPP_CSTDDEF