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