libstdc++
|
00001 // -*- C++ -*- forwarding header. 00002 00003 // Copyright (C) 1997-2017 Free Software Foundation, Inc. 00004 // 00005 // This file is part of the GNU ISO C++ Library. This library is free 00006 // software; you can redistribute it and/or modify it under the 00007 // terms of the GNU General Public License as published by the 00008 // Free Software Foundation; either version 3, or (at your option) 00009 // any later version. 00010 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 00016 // Under Section 7 of GPL version 3, you are granted additional 00017 // permissions described in the GCC Runtime Library Exception, version 00018 // 3.1, as published by the Free Software Foundation. 00019 00020 // You should have received a copy of the GNU General Public License and 00021 // a copy of the GCC Runtime Library Exception along with this program; 00022 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00023 // <http://www.gnu.org/licenses/>. 00024 00025 /** @file cstddef 00026 * This is a Standard C++ Library file. You should @c \#include this file 00027 * in your programs, rather than any of the @a *.h implementation files. 00028 * 00029 * This is the C++ version of the Standard C Library header @c stddef.h, 00030 * and its contents are (mostly) the same as that header, but are all 00031 * contained in the namespace @c std (except for names which are defined 00032 * as macros in C). 00033 */ 00034 00035 // 00036 // ISO C++ 14882: 18.1 Types 00037 // 00038 00039 #ifndef _GLIBCXX_CSTDDEF 00040 #define _GLIBCXX_CSTDDEF 1 00041 00042 #pragma GCC system_header 00043 00044 #undef __need_wchar_t 00045 #undef __need_ptrdiff_t 00046 #undef __need_size_t 00047 #undef __need_NULL 00048 #undef __need_wint_t 00049 #include <bits/c++config.h> 00050 #include <stddef.h> 00051 00052 #if __cplusplus >= 201103L 00053 namespace std 00054 { 00055 // We handle size_t, ptrdiff_t, and nullptr_t in c++config.h. 00056 using ::max_align_t; 00057 } 00058 #endif 00059 00060 #if __cplusplus > 201402L 00061 namespace std 00062 { 00063 /// std::byte 00064 enum class byte : unsigned char {}; 00065 00066 template<typename _IntegerType> struct __byte_operand; 00067 template<> struct __byte_operand<bool> { using __type = byte; }; 00068 template<> struct __byte_operand<char> { using __type = byte; }; 00069 template<> struct __byte_operand<signed char> { using __type = byte; }; 00070 template<> struct __byte_operand<unsigned char> { using __type = byte; }; 00071 #ifdef _GLIBCXX_USE_WCHAR_T 00072 template<> struct __byte_operand<wchar_t> { using __type = byte; }; 00073 #endif 00074 template<> struct __byte_operand<char16_t> { using __type = byte; }; 00075 template<> struct __byte_operand<char32_t> { using __type = byte; }; 00076 template<> struct __byte_operand<short> { using __type = byte; }; 00077 template<> struct __byte_operand<unsigned short> { using __type = byte; }; 00078 template<> struct __byte_operand<int> { using __type = byte; }; 00079 template<> struct __byte_operand<unsigned int> { using __type = byte; }; 00080 template<> struct __byte_operand<long> { using __type = byte; }; 00081 template<> struct __byte_operand<unsigned long> { using __type = byte; }; 00082 template<> struct __byte_operand<long long> { using __type = byte; }; 00083 template<> struct __byte_operand<unsigned long long> { using __type = byte; }; 00084 #if defined(__GLIBCXX_TYPE_INT_N_0) 00085 template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_0> 00086 { using __type = byte; }; 00087 template<> struct __byte_operand<unsigned __GLIBCXX_TYPE_INT_N_0> 00088 { using __type = byte; }; 00089 #endif 00090 #if defined(__GLIBCXX_TYPE_INT_N_1) 00091 template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_1> 00092 { using __type = byte; }; 00093 template<> struct __byte_operand<unsigned __GLIBCXX_TYPE_INT_N_1> 00094 { using __type = byte; }; 00095 #endif 00096 #if defined(__GLIBCXX_TYPE_INT_N_2) 00097 template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_2> 00098 { using __type = byte; }; 00099 template<> struct __byte_operand<unsigned __GLIBCXX_TYPE_INT_N_2> 00100 { using __type = byte; }; 00101 #endif 00102 template<typename _IntegerType> 00103 struct __byte_operand<const _IntegerType> 00104 : __byte_operand<_IntegerType> { }; 00105 template<typename _IntegerType> 00106 struct __byte_operand<volatile _IntegerType> 00107 : __byte_operand<_IntegerType> { }; 00108 template<typename _IntegerType> 00109 struct __byte_operand<const volatile _IntegerType> 00110 : __byte_operand<_IntegerType> { }; 00111 00112 template<typename _IntegerType> 00113 using __byte_op_t = typename __byte_operand<_IntegerType>::__type; 00114 00115 template<typename _IntegerType> 00116 constexpr __byte_op_t<_IntegerType>& 00117 operator<<=(byte& __b, _IntegerType __shift) noexcept 00118 { return __b = byte(static_cast<unsigned char>(__b) << __shift); } 00119 00120 template<typename _IntegerType> 00121 constexpr __byte_op_t<_IntegerType> 00122 operator<<(byte __b, _IntegerType __shift) noexcept 00123 { return byte(static_cast<unsigned char>(__b) << __shift); } 00124 00125 template<typename _IntegerType> 00126 constexpr __byte_op_t<_IntegerType>& 00127 operator>>=(byte& __b, _IntegerType __shift) noexcept 00128 { return __b = byte(static_cast<unsigned char>(__b) >> __shift); } 00129 00130 template<typename _IntegerType> 00131 constexpr __byte_op_t<_IntegerType> 00132 operator>>(byte __b, _IntegerType __shift) noexcept 00133 { return byte(static_cast<unsigned char>(__b) >> __shift); } 00134 00135 constexpr byte& 00136 operator|=(byte& __l, byte __r) noexcept 00137 { 00138 return __l = 00139 byte(static_cast<unsigned char>(__l) | static_cast<unsigned char>(__r)); 00140 } 00141 00142 constexpr byte 00143 operator|(byte __l, byte __r) noexcept 00144 { 00145 return 00146 byte(static_cast<unsigned char>(__l) | static_cast<unsigned char>(__r)); 00147 } 00148 00149 constexpr byte& 00150 operator&=(byte& __l, byte __r) noexcept 00151 { 00152 return __l = 00153 byte(static_cast<unsigned char>(__l) & static_cast<unsigned char>(__r)); 00154 } 00155 00156 constexpr byte 00157 operator&(byte __l, byte __r) noexcept 00158 { 00159 return 00160 byte(static_cast<unsigned char>(__l) & static_cast<unsigned char>(__r)); 00161 } 00162 00163 constexpr byte& 00164 operator^=(byte& __l, byte __r) noexcept 00165 { 00166 return __l = 00167 byte(static_cast<unsigned char>(__l) ^ static_cast<unsigned char>(__r)); 00168 } 00169 00170 constexpr byte 00171 operator^(byte __l, byte __r) noexcept 00172 { 00173 return 00174 byte(static_cast<unsigned char>(__l) ^ static_cast<unsigned char>(__r)); 00175 } 00176 00177 constexpr byte 00178 operator~(byte __b) noexcept 00179 { return byte(~static_cast<unsigned char>(__b)); } 00180 00181 template<typename _IntegerType> 00182 constexpr _IntegerType 00183 to_integer(__byte_op_t<_IntegerType> __b) noexcept 00184 { return _IntegerType(__b); } 00185 00186 } // namespace std 00187 #endif 00188 00189 #endif // _GLIBCXX_CSTDDEF