1// -*- C++ -*- forwarding header.
3// Copyright (C) 1997-2021 Free Software Foundation, Inc.
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)
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/>.
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.
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
36// ISO C++ 14882: 18.1 Types
39#ifndef _GLIBCXX_CSTDDEF
40#define _GLIBCXX_CSTDDEF 1
42#pragma GCC system_header
45#undef __need_ptrdiff_t
49#include <bits/c++config.h>
54#if __cplusplus >= 201103L
57 // We handle size_t, ptrdiff_t, and nullptr_t in c++config.h.
62#if __cplusplus >= 201703L
65_GLIBCXX_BEGIN_NAMESPACE_VERSION
66#define __cpp_lib_byte 201603
69 enum class byte : unsigned char {};
71 template<typename _IntegerType> struct __byte_operand { };
72 template<> struct __byte_operand<bool> { using __type = byte; };
73 template<> struct __byte_operand<char> { using __type = byte; };
74 template<> struct __byte_operand<signed char> { using __type = byte; };
75 template<> struct __byte_operand<unsigned char> { using __type = byte; };
76#ifdef _GLIBCXX_USE_WCHAR_T
77 template<> struct __byte_operand<wchar_t> { using __type = byte; };
79#ifdef _GLIBCXX_USE_CHAR8_T
80 template<> struct __byte_operand<char8_t> { using __type = byte; };
82 template<> struct __byte_operand<char16_t> { using __type = byte; };
83 template<> struct __byte_operand<char32_t> { using __type = byte; };
84 template<> struct __byte_operand<short> { using __type = byte; };
85 template<> struct __byte_operand<unsigned short> { using __type = byte; };
86 template<> struct __byte_operand<int> { using __type = byte; };
87 template<> struct __byte_operand<unsigned int> { using __type = byte; };
88 template<> struct __byte_operand<long> { using __type = byte; };
89 template<> struct __byte_operand<unsigned long> { using __type = byte; };
90 template<> struct __byte_operand<long long> { using __type = byte; };
91 template<> struct __byte_operand<unsigned long long> { using __type = byte; };
92#if defined(__GLIBCXX_TYPE_INT_N_0)
93 template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_0>
94 { using __type = byte; };
95 template<> struct __byte_operand<unsigned __GLIBCXX_TYPE_INT_N_0>
96 { using __type = byte; };
98#if defined(__GLIBCXX_TYPE_INT_N_1)
99 template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_1>
100 { using __type = byte; };
101 template<> struct __byte_operand<unsigned __GLIBCXX_TYPE_INT_N_1>
102 { using __type = byte; };
104#if defined(__GLIBCXX_TYPE_INT_N_2)
105 template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_2>
106 { using __type = byte; };
107 template<> struct __byte_operand<unsigned __GLIBCXX_TYPE_INT_N_2>
108 { using __type = byte; };
110 template<typename _IntegerType>
111 struct __byte_operand<const _IntegerType>
112 : __byte_operand<_IntegerType> { };
113 template<typename _IntegerType>
114 struct __byte_operand<volatile _IntegerType>
115 : __byte_operand<_IntegerType> { };
116 template<typename _IntegerType>
117 struct __byte_operand<const volatile _IntegerType>
118 : __byte_operand<_IntegerType> { };
120 template<typename _IntegerType>
121 using __byte_op_t = typename __byte_operand<_IntegerType>::__type;
123 template<typename _IntegerType>
124 [[__gnu__::__always_inline__]]
125 constexpr __byte_op_t<_IntegerType>
126 operator<<(byte __b, _IntegerType __shift) noexcept
127 { return (byte)(unsigned char)((unsigned)__b << __shift); }
129 template<typename _IntegerType>
130 [[__gnu__::__always_inline__]]
131 constexpr __byte_op_t<_IntegerType>
132 operator>>(byte __b, _IntegerType __shift) noexcept
133 { return (byte)(unsigned char)((unsigned)__b >> __shift); }
135 [[__gnu__::__always_inline__]]
137 operator|(byte __l, byte __r) noexcept
138 { return (byte)(unsigned char)((unsigned)__l | (unsigned)__r); }
140 [[__gnu__::__always_inline__]]
142 operator&(byte __l, byte __r) noexcept
143 { return (byte)(unsigned char)((unsigned)__l & (unsigned)__r); }
145 [[__gnu__::__always_inline__]]
147 operator^(byte __l, byte __r) noexcept
148 { return (byte)(unsigned char)((unsigned)__l ^ (unsigned)__r); }
150 [[__gnu__::__always_inline__]]
152 operator~(byte __b) noexcept
153 { return (byte)(unsigned char)~(unsigned)__b; }
155 template<typename _IntegerType>
156 [[__gnu__::__always_inline__]]
157 constexpr __byte_op_t<_IntegerType>&
158 operator<<=(byte& __b, _IntegerType __shift) noexcept
159 { return __b = __b << __shift; }
161 template<typename _IntegerType>
162 [[__gnu__::__always_inline__]]
163 constexpr __byte_op_t<_IntegerType>&
164 operator>>=(byte& __b, _IntegerType __shift) noexcept
165 { return __b = __b >> __shift; }
167 [[__gnu__::__always_inline__]]
169 operator|=(byte& __l, byte __r) noexcept
170 { return __l = __l | __r; }
172 [[__gnu__::__always_inline__]]
174 operator&=(byte& __l, byte __r) noexcept
175 { return __l = __l & __r; }
177 [[__gnu__::__always_inline__]]
179 operator^=(byte& __l, byte __r) noexcept
180 { return __l = __l ^ __r; }
182 template<typename _IntegerType>
183 [[nodiscard,__gnu__::__always_inline__]]
184 constexpr _IntegerType
185 to_integer(__byte_op_t<_IntegerType> __b) noexcept
186 { return _IntegerType(__b); }
188_GLIBCXX_END_NAMESPACE_VERSION
193#endif // _GLIBCXX_CSTDDEF