libstdc++
cstddef
Go to the documentation of this file.
00001 // -*- C++ -*- forwarding header.
00002 
00003 // Copyright (C) 1997-2019 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 extern "C++"
00053 {
00054 #if __cplusplus >= 201103L
00055 namespace std
00056 {
00057   // We handle size_t, ptrdiff_t, and nullptr_t in c++config.h.
00058   using ::max_align_t;
00059 }
00060 #endif // C++11
00061 
00062 #if __cplusplus >= 201703L
00063 namespace std
00064 {
00065 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00066 #define __cpp_lib_byte 201603
00067 
00068   /// std::byte
00069   enum class byte : unsigned char {};
00070 
00071   template<typename _IntegerType> struct __byte_operand { };
00072   template<> struct __byte_operand<bool> { using __type = byte; };
00073   template<> struct __byte_operand<char> { using __type = byte; };
00074   template<> struct __byte_operand<signed char> { using __type = byte; };
00075   template<> struct __byte_operand<unsigned char> { using __type = byte; };
00076 #ifdef _GLIBCXX_USE_WCHAR_T
00077   template<> struct __byte_operand<wchar_t> { using __type = byte; };
00078 #endif
00079 #ifdef _GLIBCXX_USE_CHAR8_T
00080   template<> struct __byte_operand<char8_t> { using __type = byte; };
00081 #endif
00082   template<> struct __byte_operand<char16_t> { using __type = byte; };
00083   template<> struct __byte_operand<char32_t> { using __type = byte; };
00084   template<> struct __byte_operand<short> { using __type = byte; };
00085   template<> struct __byte_operand<unsigned short> { using __type = byte; };
00086   template<> struct __byte_operand<int> { using __type = byte; };
00087   template<> struct __byte_operand<unsigned int> { using __type = byte; };
00088   template<> struct __byte_operand<long> { using __type = byte; };
00089   template<> struct __byte_operand<unsigned long> { using __type = byte; };
00090   template<> struct __byte_operand<long long> { using __type = byte; };
00091   template<> struct __byte_operand<unsigned long long> { using __type = byte; };
00092 #if defined(__GLIBCXX_TYPE_INT_N_0)
00093   template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_0>
00094   { using __type = byte; };
00095   template<> struct __byte_operand<unsigned __GLIBCXX_TYPE_INT_N_0>
00096   { using __type = byte; };
00097 #endif
00098 #if defined(__GLIBCXX_TYPE_INT_N_1)
00099   template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_1>
00100   { using __type = byte; };
00101   template<> struct __byte_operand<unsigned __GLIBCXX_TYPE_INT_N_1>
00102   { using __type = byte; };
00103 #endif
00104 #if defined(__GLIBCXX_TYPE_INT_N_2)
00105   template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_2>
00106   { using __type = byte; };
00107   template<> struct __byte_operand<unsigned __GLIBCXX_TYPE_INT_N_2>
00108   { using __type = byte; };
00109 #endif
00110   template<typename _IntegerType>
00111     struct __byte_operand<const _IntegerType>
00112     : __byte_operand<_IntegerType> { };
00113   template<typename _IntegerType>
00114     struct __byte_operand<volatile _IntegerType>
00115     : __byte_operand<_IntegerType> { };
00116   template<typename _IntegerType>
00117     struct __byte_operand<const volatile _IntegerType>
00118     : __byte_operand<_IntegerType> { };
00119 
00120   template<typename _IntegerType>
00121     using __byte_op_t = typename __byte_operand<_IntegerType>::__type;
00122 
00123   template<typename _IntegerType>
00124     constexpr __byte_op_t<_IntegerType>&
00125     operator<<=(byte& __b, _IntegerType __shift) noexcept
00126     { return __b = byte(static_cast<unsigned char>(__b) << __shift); }
00127 
00128   template<typename _IntegerType>
00129     constexpr __byte_op_t<_IntegerType>
00130     operator<<(byte __b, _IntegerType __shift) noexcept
00131     { return byte(static_cast<unsigned char>(__b) << __shift); }
00132 
00133   template<typename _IntegerType>
00134     constexpr __byte_op_t<_IntegerType>&
00135     operator>>=(byte& __b, _IntegerType __shift) noexcept
00136     { return __b = byte(static_cast<unsigned char>(__b) >> __shift); }
00137 
00138   template<typename _IntegerType>
00139     constexpr __byte_op_t<_IntegerType>
00140     operator>>(byte __b, _IntegerType __shift) noexcept
00141     { return byte(static_cast<unsigned char>(__b) >> __shift); }
00142 
00143   constexpr byte&
00144   operator|=(byte& __l, byte __r) noexcept
00145   {
00146     return __l =
00147       byte(static_cast<unsigned char>(__l) | static_cast<unsigned char>(__r));
00148   }
00149 
00150   constexpr byte
00151   operator|(byte __l, byte __r) noexcept
00152   {
00153     return
00154       byte(static_cast<unsigned char>(__l) | static_cast<unsigned char>(__r));
00155   }
00156 
00157   constexpr byte&
00158   operator&=(byte& __l, byte __r) noexcept
00159   {
00160    return __l =
00161      byte(static_cast<unsigned char>(__l) & static_cast<unsigned char>(__r));
00162   }
00163 
00164   constexpr byte
00165   operator&(byte __l, byte __r) noexcept
00166   {
00167     return
00168       byte(static_cast<unsigned char>(__l) & static_cast<unsigned char>(__r));
00169   }
00170 
00171   constexpr byte&
00172   operator^=(byte& __l, byte __r) noexcept
00173   {
00174     return __l =
00175       byte(static_cast<unsigned char>(__l) ^ static_cast<unsigned char>(__r));
00176   }
00177 
00178   constexpr byte
00179   operator^(byte __l, byte __r) noexcept
00180   {
00181     return
00182       byte(static_cast<unsigned char>(__l) ^ static_cast<unsigned char>(__r));
00183   }
00184 
00185   constexpr byte
00186   operator~(byte __b) noexcept
00187   { return byte(~static_cast<unsigned char>(__b)); }
00188 
00189   template<typename _IntegerType>
00190     constexpr _IntegerType
00191     to_integer(__byte_op_t<_IntegerType> __b) noexcept
00192     { return _IntegerType(__b); }
00193 
00194 _GLIBCXX_END_NAMESPACE_VERSION
00195 } // namespace std
00196 #endif // C++17
00197 } // extern "C++"
00198 
00199 #endif // _GLIBCXX_CSTDDEF