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