Fix my yesterday ChangeLog entry.
[official-gcc.git] / libstdc++-v3 / include / c_global / cstddef
blob0ca3b82338ad0d841eb6012477ea6a093a21b925
1 // -*- C++ -*- forwarding header.
3 // Copyright (C) 1997-2018 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library.  This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23 // <http://www.gnu.org/licenses/>.
25 /** @file cstddef
26  *  This is a Standard C++ Library file.  You should @c \#include this file
27  *  in your programs, rather than any of the @a *.h implementation files.
28  *
29  *  This is the C++ version of the Standard C Library header @c stddef.h,
30  *  and its contents are (mostly) the same as that header, but are all
31  *  contained in the namespace @c std (except for names which are defined
32  *  as macros in C).
33  */
36 // ISO C++ 14882: 18.1  Types
39 #ifndef _GLIBCXX_CSTDDEF
40 #define _GLIBCXX_CSTDDEF 1
42 #pragma GCC system_header
44 #undef __need_wchar_t
45 #undef __need_ptrdiff_t
46 #undef __need_size_t
47 #undef __need_NULL
48 #undef __need_wint_t
49 #include <bits/c++config.h>
50 #include <stddef.h>
52 extern "C++"
54 #if __cplusplus >= 201103L
55 namespace std
57   // We handle size_t, ptrdiff_t, and nullptr_t in c++config.h.
58   using ::max_align_t;
60 #endif // C++11
62 #if __cplusplus >= 201703L
63 namespace std
65 #define __cpp_lib_byte 201603
67   /// std::byte
68   enum class byte : unsigned char {};
70   template<typename _IntegerType> struct __byte_operand { };
71   template<> struct __byte_operand<bool> { using __type = byte; };
72   template<> struct __byte_operand<char> { using __type = byte; };
73   template<> struct __byte_operand<signed char> { using __type = byte; };
74   template<> struct __byte_operand<unsigned char> { using __type = byte; };
75 #ifdef _GLIBCXX_USE_WCHAR_T
76   template<> struct __byte_operand<wchar_t> { using __type = byte; };
77 #endif
78   template<> struct __byte_operand<char16_t> { using __type = byte; };
79   template<> struct __byte_operand<char32_t> { using __type = byte; };
80   template<> struct __byte_operand<short> { using __type = byte; };
81   template<> struct __byte_operand<unsigned short> { using __type = byte; };
82   template<> struct __byte_operand<int> { using __type = byte; };
83   template<> struct __byte_operand<unsigned int> { using __type = byte; };
84   template<> struct __byte_operand<long> { using __type = byte; };
85   template<> struct __byte_operand<unsigned long> { using __type = byte; };
86   template<> struct __byte_operand<long long> { using __type = byte; };
87   template<> struct __byte_operand<unsigned long long> { using __type = byte; };
88 #if defined(__GLIBCXX_TYPE_INT_N_0)
89   template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_0>
90   { using __type = byte; };
91   template<> struct __byte_operand<unsigned __GLIBCXX_TYPE_INT_N_0>
92   { using __type = byte; };
93 #endif
94 #if defined(__GLIBCXX_TYPE_INT_N_1)
95   template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_1>
96   { using __type = byte; };
97   template<> struct __byte_operand<unsigned __GLIBCXX_TYPE_INT_N_1>
98   { using __type = byte; };
99 #endif
100 #if defined(__GLIBCXX_TYPE_INT_N_2)
101   template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_2>
102   { using __type = byte; };
103   template<> struct __byte_operand<unsigned __GLIBCXX_TYPE_INT_N_2>
104   { using __type = byte; };
105 #endif
106   template<typename _IntegerType>
107     struct __byte_operand<const _IntegerType>
108     : __byte_operand<_IntegerType> { };
109   template<typename _IntegerType>
110     struct __byte_operand<volatile _IntegerType>
111     : __byte_operand<_IntegerType> { };
112   template<typename _IntegerType>
113     struct __byte_operand<const volatile _IntegerType>
114     : __byte_operand<_IntegerType> { };
116   template<typename _IntegerType>
117     using __byte_op_t = typename __byte_operand<_IntegerType>::__type;
119   template<typename _IntegerType>
120     constexpr __byte_op_t<_IntegerType>&
121     operator<<=(byte& __b, _IntegerType __shift) noexcept
122     { return __b = byte(static_cast<unsigned char>(__b) << __shift); }
124   template<typename _IntegerType>
125     constexpr __byte_op_t<_IntegerType>
126     operator<<(byte __b, _IntegerType __shift) noexcept
127     { return byte(static_cast<unsigned char>(__b) << __shift); }
129   template<typename _IntegerType>
130     constexpr __byte_op_t<_IntegerType>&
131     operator>>=(byte& __b, _IntegerType __shift) noexcept
132     { return __b = byte(static_cast<unsigned char>(__b) >> __shift); }
134   template<typename _IntegerType>
135     constexpr __byte_op_t<_IntegerType>
136     operator>>(byte __b, _IntegerType __shift) noexcept
137     { return byte(static_cast<unsigned char>(__b) >> __shift); }
139   constexpr byte&
140   operator|=(byte& __l, byte __r) noexcept
141   {
142     return __l =
143       byte(static_cast<unsigned char>(__l) | static_cast<unsigned char>(__r));
144   }
146   constexpr byte
147   operator|(byte __l, byte __r) noexcept
148   {
149     return
150       byte(static_cast<unsigned char>(__l) | static_cast<unsigned char>(__r));
151   }
153   constexpr byte&
154   operator&=(byte& __l, byte __r) noexcept
155   {
156    return __l =
157      byte(static_cast<unsigned char>(__l) & static_cast<unsigned char>(__r));
158   }
160   constexpr byte
161   operator&(byte __l, byte __r) noexcept
162   {
163     return
164       byte(static_cast<unsigned char>(__l) & static_cast<unsigned char>(__r));
165   }
167   constexpr byte&
168   operator^=(byte& __l, byte __r) noexcept
169   {
170     return __l =
171       byte(static_cast<unsigned char>(__l) ^ static_cast<unsigned char>(__r));
172   }
174   constexpr byte
175   operator^(byte __l, byte __r) noexcept
176   {
177     return
178       byte(static_cast<unsigned char>(__l) ^ static_cast<unsigned char>(__r));
179   }
181   constexpr byte
182   operator~(byte __b) noexcept
183   { return byte(~static_cast<unsigned char>(__b)); }
185   template<typename _IntegerType>
186     constexpr _IntegerType
187     to_integer(__byte_op_t<_IntegerType> __b) noexcept
188     { return _IntegerType(__b); }
190 } // namespace std
191 #endif // C++17
192 } // extern "C++"
194 #endif // _GLIBCXX_CSTDDEF