diff --git a/include/boost/endian/arithmetic.hpp b/include/boost/endian/arithmetic.hpp index fc9f8a1..e771e06 100644 --- a/include/boost/endian/arithmetic.hpp +++ b/include/boost/endian/arithmetic.hpp @@ -27,13 +27,10 @@ # pragma warning(disable:4365) // conversion ... signed/unsigned mismatch #endif -#include #include -#include -#include -#include +#include #include -#include +#include #include #include @@ -45,17 +42,6 @@ # error Platforms with CHAR_BIT != 8 are not supported # endif -# ifdef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS -# define BOOST_ENDIAN_DEFAULT_CONSTRUCT {} // C++03 -# else -# define BOOST_ENDIAN_DEFAULT_CONSTRUCT = default; // C++0x -# endif - -// g++ pre-4.6 does not support unrestricted unions, but we have no Config macro for that -# if (defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || BOOST_WORKAROUND(BOOST_GCC, < 40600)) && defined(BOOST_ENDIAN_FORCE_PODNESS) -# define BOOST_ENDIAN_NO_CTORS -# endif - # ifndef BOOST_ENDIAN_EXPLICIT_CTORS # define BOOST_ENDIAN_EXPLICIT_OPT # else @@ -69,33 +55,33 @@ namespace boost namespace endian { - template + template class endian_arithmetic; // big endian signed integer aligned types - typedef endian_arithmetic big_int8_at; - typedef endian_arithmetic big_int16_at; - typedef endian_arithmetic big_int32_at; - typedef endian_arithmetic big_int64_at; + typedef endian_arithmetic big_int8_at; + typedef endian_arithmetic big_int16_at; + typedef endian_arithmetic big_int32_at; + typedef endian_arithmetic big_int64_at; // big endian unsigned integer aligned types - typedef endian_arithmetic big_uint8_at; - typedef endian_arithmetic big_uint16_at; - typedef endian_arithmetic big_uint32_at; - typedef endian_arithmetic big_uint64_at; + typedef endian_arithmetic big_uint8_at; + typedef endian_arithmetic big_uint16_at; + typedef endian_arithmetic big_uint32_at; + typedef endian_arithmetic big_uint64_at; // little endian signed integer aligned types - typedef endian_arithmetic little_int8_at; - typedef endian_arithmetic little_int16_at; - typedef endian_arithmetic little_int32_at; - typedef endian_arithmetic little_int64_at; + typedef endian_arithmetic little_int8_at; + typedef endian_arithmetic little_int16_at; + typedef endian_arithmetic little_int32_at; + typedef endian_arithmetic little_int64_at; // little endian unsigned integer aligned types - typedef endian_arithmetic little_uint8_at; - typedef endian_arithmetic little_uint16_at; - typedef endian_arithmetic little_uint32_at; - typedef endian_arithmetic little_uint64_at; + typedef endian_arithmetic little_uint8_at; + typedef endian_arithmetic little_uint16_at; + typedef endian_arithmetic little_uint32_at; + typedef endian_arithmetic little_uint64_at; // aligned floating point types typedef endian_arithmetic big_float32_at; @@ -107,64 +93,64 @@ namespace endian // types are superior for this use case // big endian signed integer unaligned types - typedef endian_arithmetic big_int8_t; - typedef endian_arithmetic big_int16_t; - typedef endian_arithmetic big_int24_t; - typedef endian_arithmetic big_int32_t; - typedef endian_arithmetic big_int40_t; - typedef endian_arithmetic big_int48_t; - typedef endian_arithmetic big_int56_t; - typedef endian_arithmetic big_int64_t; + typedef endian_arithmetic big_int8_t; + typedef endian_arithmetic big_int16_t; + typedef endian_arithmetic big_int24_t; + typedef endian_arithmetic big_int32_t; + typedef endian_arithmetic big_int40_t; + typedef endian_arithmetic big_int48_t; + typedef endian_arithmetic big_int56_t; + typedef endian_arithmetic big_int64_t; // big endian unsigned integer unaligned types - typedef endian_arithmetic big_uint8_t; - typedef endian_arithmetic big_uint16_t; - typedef endian_arithmetic big_uint24_t; - typedef endian_arithmetic big_uint32_t; - typedef endian_arithmetic big_uint40_t; - typedef endian_arithmetic big_uint48_t; - typedef endian_arithmetic big_uint56_t; - typedef endian_arithmetic big_uint64_t; + typedef endian_arithmetic big_uint8_t; + typedef endian_arithmetic big_uint16_t; + typedef endian_arithmetic big_uint24_t; + typedef endian_arithmetic big_uint32_t; + typedef endian_arithmetic big_uint40_t; + typedef endian_arithmetic big_uint48_t; + typedef endian_arithmetic big_uint56_t; + typedef endian_arithmetic big_uint64_t; // little endian signed integer unaligned types - typedef endian_arithmetic little_int8_t; - typedef endian_arithmetic little_int16_t; - typedef endian_arithmetic little_int24_t; - typedef endian_arithmetic little_int32_t; - typedef endian_arithmetic little_int40_t; - typedef endian_arithmetic little_int48_t; - typedef endian_arithmetic little_int56_t; - typedef endian_arithmetic little_int64_t; + typedef endian_arithmetic little_int8_t; + typedef endian_arithmetic little_int16_t; + typedef endian_arithmetic little_int24_t; + typedef endian_arithmetic little_int32_t; + typedef endian_arithmetic little_int40_t; + typedef endian_arithmetic little_int48_t; + typedef endian_arithmetic little_int56_t; + typedef endian_arithmetic little_int64_t; // little endian unsigned integer unaligned types - typedef endian_arithmetic little_uint8_t; - typedef endian_arithmetic little_uint16_t; - typedef endian_arithmetic little_uint24_t; - typedef endian_arithmetic little_uint32_t; - typedef endian_arithmetic little_uint40_t; - typedef endian_arithmetic little_uint48_t; - typedef endian_arithmetic little_uint56_t; - typedef endian_arithmetic little_uint64_t; + typedef endian_arithmetic little_uint8_t; + typedef endian_arithmetic little_uint16_t; + typedef endian_arithmetic little_uint24_t; + typedef endian_arithmetic little_uint32_t; + typedef endian_arithmetic little_uint40_t; + typedef endian_arithmetic little_uint48_t; + typedef endian_arithmetic little_uint56_t; + typedef endian_arithmetic little_uint64_t; // native endian signed integer unaligned types - typedef endian_arithmetic native_int8_t; - typedef endian_arithmetic native_int16_t; - typedef endian_arithmetic native_int24_t; - typedef endian_arithmetic native_int32_t; - typedef endian_arithmetic native_int40_t; - typedef endian_arithmetic native_int48_t; - typedef endian_arithmetic native_int56_t; - typedef endian_arithmetic native_int64_t; + typedef endian_arithmetic native_int8_t; + typedef endian_arithmetic native_int16_t; + typedef endian_arithmetic native_int24_t; + typedef endian_arithmetic native_int32_t; + typedef endian_arithmetic native_int40_t; + typedef endian_arithmetic native_int48_t; + typedef endian_arithmetic native_int56_t; + typedef endian_arithmetic native_int64_t; // native endian unsigned integer unaligned types - typedef endian_arithmetic native_uint8_t; - typedef endian_arithmetic native_uint16_t; - typedef endian_arithmetic native_uint24_t; - typedef endian_arithmetic native_uint32_t; - typedef endian_arithmetic native_uint40_t; - typedef endian_arithmetic native_uint48_t; - typedef endian_arithmetic native_uint56_t; - typedef endian_arithmetic native_uint64_t; + typedef endian_arithmetic native_uint8_t; + typedef endian_arithmetic native_uint16_t; + typedef endian_arithmetic native_uint24_t; + typedef endian_arithmetic native_uint32_t; + typedef endian_arithmetic native_uint40_t; + typedef endian_arithmetic native_uint48_t; + typedef endian_arithmetic native_uint56_t; + typedef endian_arithmetic native_uint64_t; // unaligned floating point types typedef endian_arithmetic big_float32_t; @@ -176,8 +162,8 @@ namespace endian //---------------------------------- end synopsis ------------------------------------// -template +template class endian_arithmetic { private: @@ -198,7 +184,7 @@ public: #ifndef BOOST_ENDIAN_NO_CTORS - endian_arithmetic() BOOST_ENDIAN_DEFAULT_CONSTRUCT + endian_arithmetic() = default; BOOST_ENDIAN_EXPLICIT_OPT endian_arithmetic( T val ) BOOST_NOEXCEPT: buf_( val ) { diff --git a/include/boost/endian/buffers.hpp b/include/boost/endian/buffers.hpp index d0278c8..92701df 100644 --- a/include/boost/endian/buffers.hpp +++ b/include/boost/endian/buffers.hpp @@ -27,14 +27,11 @@ # pragma warning(disable: 4127) // conditional expression is constant #endif -#include #include #include -#include -#include -#include +#include #include -#include +#include #include #include #include @@ -47,17 +44,6 @@ # error Platforms with CHAR_BIT != 8 are not supported # endif -# ifdef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS -# define BOOST_ENDIAN_DEFAULT_CONSTRUCT {} // C++03 -# else -# define BOOST_ENDIAN_DEFAULT_CONSTRUCT = default; // C++0x -# endif - -// g++ pre-4.6 does not support unrestricted unions, but we have no Config macro for that -# if (defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || BOOST_WORKAROUND(BOOST_GCC, < 40600)) && defined(BOOST_ENDIAN_FORCE_PODNESS) -# define BOOST_ENDIAN_NO_CTORS -# endif - //---------------------------------- synopsis ----------------------------------------// namespace boost @@ -65,40 +51,40 @@ namespace boost namespace endian { - BOOST_SCOPED_ENUM_START(align) + enum class align {no, yes # ifdef BOOST_ENDIAN_DEPRECATED_NAMES , unaligned = no, aligned = yes # endif - }; BOOST_SCOPED_ENUM_END + }; - template + template class endian_buffer; // aligned big endian signed integer buffers - typedef endian_buffer big_int8_buf_at; - typedef endian_buffer big_int16_buf_at; - typedef endian_buffer big_int32_buf_at; - typedef endian_buffer big_int64_buf_at; + typedef endian_buffer big_int8_buf_at; + typedef endian_buffer big_int16_buf_at; + typedef endian_buffer big_int32_buf_at; + typedef endian_buffer big_int64_buf_at; // aligned big endian unsigned integer buffers - typedef endian_buffer big_uint8_buf_at; - typedef endian_buffer big_uint16_buf_at; - typedef endian_buffer big_uint32_buf_at; - typedef endian_buffer big_uint64_buf_at; + typedef endian_buffer big_uint8_buf_at; + typedef endian_buffer big_uint16_buf_at; + typedef endian_buffer big_uint32_buf_at; + typedef endian_buffer big_uint64_buf_at; // aligned little endian signed integer buffers - typedef endian_buffer little_int8_buf_at; - typedef endian_buffer little_int16_buf_at; - typedef endian_buffer little_int32_buf_at; - typedef endian_buffer little_int64_buf_at; + typedef endian_buffer little_int8_buf_at; + typedef endian_buffer little_int16_buf_at; + typedef endian_buffer little_int32_buf_at; + typedef endian_buffer little_int64_buf_at; // aligned little endian unsigned integer buffers - typedef endian_buffer little_uint8_buf_at; - typedef endian_buffer little_uint16_buf_at; - typedef endian_buffer little_uint32_buf_at; - typedef endian_buffer little_uint64_buf_at; + typedef endian_buffer little_uint8_buf_at; + typedef endian_buffer little_uint16_buf_at; + typedef endian_buffer little_uint32_buf_at; + typedef endian_buffer little_uint64_buf_at; // aligned floating point buffers typedef endian_buffer big_float32_buf_at; @@ -110,64 +96,64 @@ namespace endian // types are superior for this use case // unaligned big endian signed integer buffers - typedef endian_buffer big_int8_buf_t; - typedef endian_buffer big_int16_buf_t; - typedef endian_buffer big_int24_buf_t; - typedef endian_buffer big_int32_buf_t; - typedef endian_buffer big_int40_buf_t; - typedef endian_buffer big_int48_buf_t; - typedef endian_buffer big_int56_buf_t; - typedef endian_buffer big_int64_buf_t; + typedef endian_buffer big_int8_buf_t; + typedef endian_buffer big_int16_buf_t; + typedef endian_buffer big_int24_buf_t; + typedef endian_buffer big_int32_buf_t; + typedef endian_buffer big_int40_buf_t; + typedef endian_buffer big_int48_buf_t; + typedef endian_buffer big_int56_buf_t; + typedef endian_buffer big_int64_buf_t; // unaligned big endian unsigned integer buffers - typedef endian_buffer big_uint8_buf_t; - typedef endian_buffer big_uint16_buf_t; - typedef endian_buffer big_uint24_buf_t; - typedef endian_buffer big_uint32_buf_t; - typedef endian_buffer big_uint40_buf_t; - typedef endian_buffer big_uint48_buf_t; - typedef endian_buffer big_uint56_buf_t; - typedef endian_buffer big_uint64_buf_t; + typedef endian_buffer big_uint8_buf_t; + typedef endian_buffer big_uint16_buf_t; + typedef endian_buffer big_uint24_buf_t; + typedef endian_buffer big_uint32_buf_t; + typedef endian_buffer big_uint40_buf_t; + typedef endian_buffer big_uint48_buf_t; + typedef endian_buffer big_uint56_buf_t; + typedef endian_buffer big_uint64_buf_t; // unaligned little endian signed integer buffers - typedef endian_buffer little_int8_buf_t; - typedef endian_buffer little_int16_buf_t; - typedef endian_buffer little_int24_buf_t; - typedef endian_buffer little_int32_buf_t; - typedef endian_buffer little_int40_buf_t; - typedef endian_buffer little_int48_buf_t; - typedef endian_buffer little_int56_buf_t; - typedef endian_buffer little_int64_buf_t; + typedef endian_buffer little_int8_buf_t; + typedef endian_buffer little_int16_buf_t; + typedef endian_buffer little_int24_buf_t; + typedef endian_buffer little_int32_buf_t; + typedef endian_buffer little_int40_buf_t; + typedef endian_buffer little_int48_buf_t; + typedef endian_buffer little_int56_buf_t; + typedef endian_buffer little_int64_buf_t; // unaligned little endian unsigned integer buffers - typedef endian_buffer little_uint8_buf_t; - typedef endian_buffer little_uint16_buf_t; - typedef endian_buffer little_uint24_buf_t; - typedef endian_buffer little_uint32_buf_t; - typedef endian_buffer little_uint40_buf_t; - typedef endian_buffer little_uint48_buf_t; - typedef endian_buffer little_uint56_buf_t; - typedef endian_buffer little_uint64_buf_t; + typedef endian_buffer little_uint8_buf_t; + typedef endian_buffer little_uint16_buf_t; + typedef endian_buffer little_uint24_buf_t; + typedef endian_buffer little_uint32_buf_t; + typedef endian_buffer little_uint40_buf_t; + typedef endian_buffer little_uint48_buf_t; + typedef endian_buffer little_uint56_buf_t; + typedef endian_buffer little_uint64_buf_t; // unaligned native endian signed integer buffers - typedef endian_buffer native_int8_buf_t; - typedef endian_buffer native_int16_buf_t; - typedef endian_buffer native_int24_buf_t; - typedef endian_buffer native_int32_buf_t; - typedef endian_buffer native_int40_buf_t; - typedef endian_buffer native_int48_buf_t; - typedef endian_buffer native_int56_buf_t; - typedef endian_buffer native_int64_buf_t; + typedef endian_buffer native_int8_buf_t; + typedef endian_buffer native_int16_buf_t; + typedef endian_buffer native_int24_buf_t; + typedef endian_buffer native_int32_buf_t; + typedef endian_buffer native_int40_buf_t; + typedef endian_buffer native_int48_buf_t; + typedef endian_buffer native_int56_buf_t; + typedef endian_buffer native_int64_buf_t; // unaligned native endian unsigned integer buffers - typedef endian_buffer native_uint8_buf_t; - typedef endian_buffer native_uint16_buf_t; - typedef endian_buffer native_uint24_buf_t; - typedef endian_buffer native_uint32_buf_t; - typedef endian_buffer native_uint40_buf_t; - typedef endian_buffer native_uint48_buf_t; - typedef endian_buffer native_uint56_buf_t; - typedef endian_buffer native_uint64_buf_t; + typedef endian_buffer native_uint8_buf_t; + typedef endian_buffer native_uint16_buf_t; + typedef endian_buffer native_uint24_buf_t; + typedef endian_buffer native_uint32_buf_t; + typedef endian_buffer native_uint40_buf_t; + typedef endian_buffer native_uint48_buf_t; + typedef endian_buffer native_uint56_buf_t; + typedef endian_buffer native_uint64_buf_t; // unaligned floating point buffers typedef endian_buffer big_float32_buf_t; @@ -178,8 +164,8 @@ namespace endian typedef endian_buffer native_float64_buf_t; // Stream inserter - template + template std::basic_ostream& operator<<(std::basic_ostream& os, const endian_buffer& x) @@ -188,8 +174,8 @@ namespace endian } // Stream extractor - template + template std::basic_istream& operator>>(std::basic_istream& is, endian_buffer& x) @@ -216,14 +202,14 @@ namespace endian // unaligned endian_buffer specialization -template< BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits > +template< order Order, class T, std::size_t n_bits > class endian_buffer { #ifdef BOOST_ENDIAN_NO_CTORS public: #endif - BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits ); + BOOST_ENDIAN_STATIC_ASSERT( (n_bits/8)*8 == n_bits ); unsigned char value_[ n_bits / 8 ]; @@ -233,7 +219,7 @@ public: #ifndef BOOST_ENDIAN_NO_CTORS - endian_buffer() BOOST_ENDIAN_DEFAULT_CONSTRUCT + endian_buffer() = default; explicit endian_buffer( T val ) BOOST_NOEXCEPT { @@ -268,13 +254,13 @@ public: // aligned endian_buffer specialization -template< BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits > +template< order Order, class T, std::size_t n_bits > class endian_buffer { private: - BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits ); - BOOST_STATIC_ASSERT( sizeof(T) == n_bits/8 ); + BOOST_ENDIAN_STATIC_ASSERT( (n_bits/8)*8 == n_bits ); + BOOST_ENDIAN_STATIC_ASSERT( sizeof(T) == n_bits/8 ); union { @@ -288,7 +274,7 @@ public: #ifndef BOOST_ENDIAN_NO_CTORS - endian_buffer() BOOST_ENDIAN_DEFAULT_CONSTRUCT + endian_buffer() = default; explicit endian_buffer( T val ) BOOST_NOEXCEPT { @@ -326,8 +312,8 @@ class endian_buffer { private: - BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits ); - BOOST_STATIC_ASSERT( sizeof(T) == n_bits/8 ); + BOOST_ENDIAN_STATIC_ASSERT( (n_bits/8)*8 == n_bits ); + BOOST_ENDIAN_STATIC_ASSERT( sizeof(T) == n_bits/8 ); T value_; @@ -337,7 +323,7 @@ public: #ifndef BOOST_ENDIAN_NO_CTORS - endian_buffer() BOOST_ENDIAN_DEFAULT_CONSTRUCT + endian_buffer() = default; explicit endian_buffer( T val ) BOOST_NOEXCEPT: value_( val ) { diff --git a/include/boost/endian/conversion.hpp b/include/boost/endian/conversion.hpp index 067a832..c284c8e 100644 --- a/include/boost/endian/conversion.hpp +++ b/include/boost/endian/conversion.hpp @@ -8,17 +8,14 @@ #ifndef BOOST_ENDIAN_CONVERSION_HPP #define BOOST_ENDIAN_CONVERSION_HPP -#include #include #include #include #include -#include -#include -#include -#include -#include +#include #include +#include +#include //------------------------------------- synopsis ---------------------------------------// @@ -66,7 +63,7 @@ namespace endian // Returns: x if native endian order is little, otherwise endian_reverse(x) // generic conditional reverse byte order - template inline BOOST_CONSTEXPR EndianReversible conditional_reverse(EndianReversible from) BOOST_NOEXCEPT; // Returns: If From == To have different values, from. @@ -77,7 +74,7 @@ namespace endian // runtime conditional reverse byte order template inline BOOST_CONSTEXPR EndianReversible conditional_reverse(EndianReversible from, - BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order) + order from_order, order to_order) BOOST_NOEXCEPT; // Returns: from_order == to_order ? from : endian_reverse(from). @@ -133,14 +130,14 @@ namespace endian // Effects: none if native byte-order is little, otherwise endian_reverse_inplace(x); // generic conditional reverse in place - template inline void conditional_reverse_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT; // runtime reverse in place template inline void conditional_reverse_inplace(EndianReversibleInplace& x, - BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order) + order from_order, order to_order) BOOST_NOEXCEPT; //----------------------------------- end synopsis -------------------------------------// @@ -173,13 +170,13 @@ namespace detail { template -inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversible x, boost::true_type ) BOOST_NOEXCEPT +inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversible x, std::true_type ) BOOST_NOEXCEPT { return x; } template -inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversible x, boost::false_type ) BOOST_NOEXCEPT +inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversible x, std::false_type ) BOOST_NOEXCEPT { return endian_reverse( x ); } @@ -187,19 +184,19 @@ inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversib } // namespace detail // generic conditional reverse -template +template inline BOOST_CONSTEXPR EndianReversible conditional_reverse( EndianReversible x ) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( boost::is_class::value || detail::is_endian_reversible::value ); - return detail::conditional_reverse_impl( x, boost::integral_constant() ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_class::value || detail::is_endian_reversible::value ); + return detail::conditional_reverse_impl( x, std::integral_constant() ); } // runtime conditional reverse template inline BOOST_CONSTEXPR EndianReversible conditional_reverse( EndianReversible x, - BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order ) BOOST_NOEXCEPT + order from_order, order to_order ) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( boost::is_class::value || detail::is_endian_reversible::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_class::value || detail::is_endian_reversible::value ); return from_order == to_order? x: endian_reverse( x ); } @@ -235,12 +232,12 @@ namespace detail { template -inline void conditional_reverse_inplace_impl( EndianReversibleInplace&, boost::true_type ) BOOST_NOEXCEPT +inline void conditional_reverse_inplace_impl( EndianReversibleInplace&, std::true_type ) BOOST_NOEXCEPT { } template -inline void conditional_reverse_inplace_impl( EndianReversibleInplace& x, boost::false_type ) BOOST_NOEXCEPT +inline void conditional_reverse_inplace_impl( EndianReversibleInplace& x, std::false_type ) BOOST_NOEXCEPT { endian_reverse_inplace( x ); } @@ -248,25 +245,25 @@ inline void conditional_reverse_inplace_impl( EndianReversibleInplace& x, boost: } // namespace detail // generic conditional reverse in place -template +template inline void conditional_reverse_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( - boost::is_class::value || - boost::is_array::value || + BOOST_ENDIAN_STATIC_ASSERT( + std::is_class::value || + std::is_array::value || detail::is_endian_reversible_inplace::value ); - detail::conditional_reverse_inplace_impl( x, boost::integral_constant() ); + detail::conditional_reverse_inplace_impl( x, std::integral_constant() ); } // runtime reverse in place template inline void conditional_reverse_inplace( EndianReversibleInplace& x, - BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order ) BOOST_NOEXCEPT + order from_order, order to_order ) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( - boost::is_class::value || - boost::is_array::value || + BOOST_ENDIAN_STATIC_ASSERT( + std::is_class::value || + std::is_array::value || detail::is_endian_reversible_inplace::value ); if( from_order != to_order ) @@ -279,310 +276,310 @@ inline void conditional_reverse_inplace( EndianReversibleInplace& x, // load 16 -inline boost::int16_t load_little_s16( unsigned char const * p ) BOOST_NOEXCEPT +inline std::int16_t load_little_s16( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } -inline boost::uint16_t load_little_u16( unsigned char const * p ) BOOST_NOEXCEPT +inline std::uint16_t load_little_u16( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } -inline boost::int16_t load_big_s16( unsigned char const * p ) BOOST_NOEXCEPT +inline std::int16_t load_big_s16( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } -inline boost::uint16_t load_big_u16( unsigned char const * p ) BOOST_NOEXCEPT +inline std::uint16_t load_big_u16( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } // load 24 -inline boost::int32_t load_little_s24( unsigned char const * p ) BOOST_NOEXCEPT +inline std::int32_t load_little_s24( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } -inline boost::uint32_t load_little_u24( unsigned char const * p ) BOOST_NOEXCEPT +inline std::uint32_t load_little_u24( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } -inline boost::int32_t load_big_s24( unsigned char const * p ) BOOST_NOEXCEPT +inline std::int32_t load_big_s24( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } -inline boost::uint32_t load_big_u24( unsigned char const * p ) BOOST_NOEXCEPT +inline std::uint32_t load_big_u24( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } // load 32 -inline boost::int32_t load_little_s32( unsigned char const * p ) BOOST_NOEXCEPT +inline std::int32_t load_little_s32( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } -inline boost::uint32_t load_little_u32( unsigned char const * p ) BOOST_NOEXCEPT +inline std::uint32_t load_little_u32( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } -inline boost::int32_t load_big_s32( unsigned char const * p ) BOOST_NOEXCEPT +inline std::int32_t load_big_s32( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } -inline boost::uint32_t load_big_u32( unsigned char const * p ) BOOST_NOEXCEPT +inline std::uint32_t load_big_u32( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } // load 40 -inline boost::int64_t load_little_s40( unsigned char const * p ) BOOST_NOEXCEPT +inline std::int64_t load_little_s40( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } -inline boost::uint64_t load_little_u40( unsigned char const * p ) BOOST_NOEXCEPT +inline std::uint64_t load_little_u40( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } -inline boost::int64_t load_big_s40( unsigned char const * p ) BOOST_NOEXCEPT +inline std::int64_t load_big_s40( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } -inline boost::uint64_t load_big_u40( unsigned char const * p ) BOOST_NOEXCEPT +inline std::uint64_t load_big_u40( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } // load 48 -inline boost::int64_t load_little_s48( unsigned char const * p ) BOOST_NOEXCEPT +inline std::int64_t load_little_s48( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } -inline boost::uint64_t load_little_u48( unsigned char const * p ) BOOST_NOEXCEPT +inline std::uint64_t load_little_u48( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } -inline boost::int64_t load_big_s48( unsigned char const * p ) BOOST_NOEXCEPT +inline std::int64_t load_big_s48( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } -inline boost::uint64_t load_big_u48( unsigned char const * p ) BOOST_NOEXCEPT +inline std::uint64_t load_big_u48( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } // load 56 -inline boost::int64_t load_little_s56( unsigned char const * p ) BOOST_NOEXCEPT +inline std::int64_t load_little_s56( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } -inline boost::uint64_t load_little_u56( unsigned char const * p ) BOOST_NOEXCEPT +inline std::uint64_t load_little_u56( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } -inline boost::int64_t load_big_s56( unsigned char const * p ) BOOST_NOEXCEPT +inline std::int64_t load_big_s56( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } -inline boost::uint64_t load_big_u56( unsigned char const * p ) BOOST_NOEXCEPT +inline std::uint64_t load_big_u56( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } // load 64 -inline boost::int64_t load_little_s64( unsigned char const * p ) BOOST_NOEXCEPT +inline std::int64_t load_little_s64( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } -inline boost::uint64_t load_little_u64( unsigned char const * p ) BOOST_NOEXCEPT +inline std::uint64_t load_little_u64( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } -inline boost::int64_t load_big_s64( unsigned char const * p ) BOOST_NOEXCEPT +inline std::int64_t load_big_s64( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } -inline boost::uint64_t load_big_u64( unsigned char const * p ) BOOST_NOEXCEPT +inline std::uint64_t load_big_u64( unsigned char const * p ) BOOST_NOEXCEPT { - return boost::endian::endian_load( p ); + return boost::endian::endian_load( p ); } // store 16 -inline void store_little_s16( unsigned char * p, boost::int16_t v ) +inline void store_little_s16( unsigned char * p, std::int16_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } -inline void store_little_u16( unsigned char * p, boost::uint16_t v ) +inline void store_little_u16( unsigned char * p, std::uint16_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } -inline void store_big_s16( unsigned char * p, boost::int16_t v ) +inline void store_big_s16( unsigned char * p, std::int16_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } -inline void store_big_u16( unsigned char * p, boost::uint16_t v ) +inline void store_big_u16( unsigned char * p, std::uint16_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } // store 24 -inline void store_little_s24( unsigned char * p, boost::int32_t v ) +inline void store_little_s24( unsigned char * p, std::int32_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } -inline void store_little_u24( unsigned char * p, boost::uint32_t v ) +inline void store_little_u24( unsigned char * p, std::uint32_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } -inline void store_big_s24( unsigned char * p, boost::int32_t v ) +inline void store_big_s24( unsigned char * p, std::int32_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } -inline void store_big_u24( unsigned char * p, boost::uint32_t v ) +inline void store_big_u24( unsigned char * p, std::uint32_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } // store 32 -inline void store_little_s32( unsigned char * p, boost::int32_t v ) +inline void store_little_s32( unsigned char * p, std::int32_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } -inline void store_little_u32( unsigned char * p, boost::uint32_t v ) +inline void store_little_u32( unsigned char * p, std::uint32_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } -inline void store_big_s32( unsigned char * p, boost::int32_t v ) +inline void store_big_s32( unsigned char * p, std::int32_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } -inline void store_big_u32( unsigned char * p, boost::uint32_t v ) +inline void store_big_u32( unsigned char * p, std::uint32_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } // store 40 -inline void store_little_s40( unsigned char * p, boost::int64_t v ) +inline void store_little_s40( unsigned char * p, std::int64_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } -inline void store_little_u40( unsigned char * p, boost::uint64_t v ) +inline void store_little_u40( unsigned char * p, std::uint64_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } -inline void store_big_s40( unsigned char * p, boost::int64_t v ) +inline void store_big_s40( unsigned char * p, std::int64_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } -inline void store_big_u40( unsigned char * p, boost::uint64_t v ) +inline void store_big_u40( unsigned char * p, std::uint64_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } // store 48 -inline void store_little_s48( unsigned char * p, boost::int64_t v ) +inline void store_little_s48( unsigned char * p, std::int64_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } -inline void store_little_u48( unsigned char * p, boost::uint64_t v ) +inline void store_little_u48( unsigned char * p, std::uint64_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } -inline void store_big_s48( unsigned char * p, boost::int64_t v ) +inline void store_big_s48( unsigned char * p, std::int64_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } -inline void store_big_u48( unsigned char * p, boost::uint64_t v ) +inline void store_big_u48( unsigned char * p, std::uint64_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } // store 56 -inline void store_little_s56( unsigned char * p, boost::int64_t v ) +inline void store_little_s56( unsigned char * p, std::int64_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } -inline void store_little_u56( unsigned char * p, boost::uint64_t v ) +inline void store_little_u56( unsigned char * p, std::uint64_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } -inline void store_big_s56( unsigned char * p, boost::int64_t v ) +inline void store_big_s56( unsigned char * p, std::int64_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } -inline void store_big_u56( unsigned char * p, boost::uint64_t v ) +inline void store_big_u56( unsigned char * p, std::uint64_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } // store 64 -inline void store_little_s64( unsigned char * p, boost::int64_t v ) +inline void store_little_s64( unsigned char * p, std::int64_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } -inline void store_little_u64( unsigned char * p, boost::uint64_t v ) +inline void store_little_u64( unsigned char * p, std::uint64_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } -inline void store_big_s64( unsigned char * p, boost::int64_t v ) +inline void store_big_s64( unsigned char * p, std::int64_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } -inline void store_big_u64( unsigned char * p, boost::uint64_t v ) +inline void store_big_u64( unsigned char * p, std::uint64_t v ) { - boost::endian::endian_store( p, v ); + boost::endian::endian_store( p, v ); } } // namespace endian diff --git a/include/boost/endian/detail/endian_load.hpp b/include/boost/endian/detail/endian_load.hpp index 8dd9a20..eac2407 100644 --- a/include/boost/endian/detail/endian_load.hpp +++ b/include/boost/endian/detail/endian_load.hpp @@ -10,10 +10,8 @@ #include #include #include -#include -#include -#include -#include +#include +#include #include #include @@ -25,7 +23,7 @@ namespace endian namespace detail { -template struct endian_load_impl +template struct endian_load_impl { }; @@ -38,11 +36,11 @@ template +template inline T endian_load( unsigned char const * p ) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8 ); - BOOST_STATIC_ASSERT( N >= 1 && N <= sizeof(T) ); + BOOST_ENDIAN_STATIC_ASSERT( sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8 ); + BOOST_ENDIAN_STATIC_ASSERT( N >= 1 && N <= sizeof(T) ); return detail::endian_load_impl()( p ); } @@ -52,11 +50,11 @@ namespace detail // same endianness, same size -template struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_trivially_copyable::value ); + BOOST_ENDIAN_STATIC_ASSERT( is_trivially_copyable::value ); T t; std::memcpy( &t, p, N ); @@ -66,11 +64,11 @@ template struct endian_load_ // same size, reverse endianness -template struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_trivially_copyable::value ); + BOOST_ENDIAN_STATIC_ASSERT( is_trivially_copyable::value ); typename integral_by_size::type tmp; std::memcpy( &tmp, p, N ); @@ -85,30 +83,30 @@ template 2 -template struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 2 ]; tmp[0] = p[0]; - tmp[1] = boost::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; + tmp[1] = std::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; return boost::endian::endian_load( tmp ); } }; -template struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 2 ]; - tmp[0] = boost::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; + tmp[0] = std::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; tmp[1] = p[0]; return boost::endian::endian_load( tmp ); @@ -117,15 +115,15 @@ template struct endian_load_impl 4 -template struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 4 ]; - unsigned char fill = boost::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; + unsigned char fill = std::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; tmp[0] = p[0]; tmp[1] = fill; @@ -136,15 +134,15 @@ template struct endian_load_impl struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 4 ]; - unsigned char fill = boost::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; + unsigned char fill = std::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; tmp[0] = fill; tmp[1] = fill; @@ -157,15 +155,15 @@ template struct endian_load_impl 4 -template struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 4 ]; - unsigned char fill = boost::is_signed::value && ( p[1] & 0x80 )? 0xFF: 0x00; + unsigned char fill = std::is_signed::value && ( p[1] & 0x80 )? 0xFF: 0x00; tmp[0] = p[0]; tmp[1] = p[1]; @@ -176,15 +174,15 @@ template struct endian_load_impl struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 4 ]; - unsigned char fill = boost::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; + unsigned char fill = std::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; tmp[0] = fill; tmp[1] = fill; @@ -197,32 +195,32 @@ template struct endian_load_impl 4 -template struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 4 ]; tmp[0] = p[0]; tmp[1] = p[1]; tmp[2] = p[2]; - tmp[3] = boost::is_signed::value && ( p[2] & 0x80 )? 0xFF: 0x00; + tmp[3] = std::is_signed::value && ( p[2] & 0x80 )? 0xFF: 0x00; return boost::endian::endian_load( tmp ); } }; -template struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 4 ]; - tmp[0] = boost::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; + tmp[0] = std::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; tmp[1] = p[0]; tmp[2] = p[1]; tmp[3] = p[2]; @@ -233,15 +231,15 @@ template struct endian_load_impl 8 -template struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; - unsigned char fill = boost::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; + unsigned char fill = std::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; tmp[0] = p[0]; @@ -257,15 +255,15 @@ template struct endian_load_impl struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; - unsigned char fill = boost::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; + unsigned char fill = std::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; tmp[0] = fill; tmp[1] = fill; @@ -283,15 +281,15 @@ template struct endian_load_impl 8 -template struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; - unsigned char fill = boost::is_signed::value && ( p[1] & 0x80 )? 0xFF: 0x00; + unsigned char fill = std::is_signed::value && ( p[1] & 0x80 )? 0xFF: 0x00; tmp[0] = p[0]; tmp[1] = p[1]; @@ -307,15 +305,15 @@ template struct endian_load_impl struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; - unsigned char fill = boost::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; + unsigned char fill = std::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; tmp[0] = fill; tmp[1] = fill; @@ -333,15 +331,15 @@ template struct endian_load_impl 8 -template struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; - unsigned char fill = boost::is_signed::value && ( p[2] & 0x80 )? 0xFF: 0x00; + unsigned char fill = std::is_signed::value && ( p[2] & 0x80 )? 0xFF: 0x00; tmp[0] = p[0]; tmp[1] = p[1]; @@ -357,15 +355,15 @@ template struct endian_load_impl struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; - unsigned char fill = boost::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; + unsigned char fill = std::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; tmp[0] = fill; tmp[1] = fill; @@ -383,15 +381,15 @@ template struct endian_load_impl 8 -template struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; - unsigned char fill = boost::is_signed::value && ( p[3] & 0x80 )? 0xFF: 0x00; + unsigned char fill = std::is_signed::value && ( p[3] & 0x80 )? 0xFF: 0x00; tmp[0] = p[0]; tmp[1] = p[1]; @@ -407,15 +405,15 @@ template struct endian_load_impl struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; - unsigned char fill = boost::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; + unsigned char fill = std::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; tmp[0] = fill; tmp[1] = fill; @@ -433,15 +431,15 @@ template struct endian_load_impl 8 -template struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; - unsigned char fill = boost::is_signed::value && ( p[4] & 0x80 )? 0xFF: 0x00; + unsigned char fill = std::is_signed::value && ( p[4] & 0x80 )? 0xFF: 0x00; tmp[0] = p[0]; tmp[1] = p[1]; @@ -457,15 +455,15 @@ template struct endian_load_impl struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; - unsigned char fill = boost::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; + unsigned char fill = std::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; tmp[0] = fill; tmp[1] = fill; @@ -483,15 +481,15 @@ template struct endian_load_impl 8 -template struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; - unsigned char fill = boost::is_signed::value && ( p[5] & 0x80 )? 0xFF: 0x00; + unsigned char fill = std::is_signed::value && ( p[5] & 0x80 )? 0xFF: 0x00; tmp[0] = p[0]; tmp[1] = p[1]; @@ -507,15 +505,15 @@ template struct endian_load_impl struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; - unsigned char fill = boost::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; + unsigned char fill = std::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; tmp[0] = fill; tmp[1] = fill; @@ -533,15 +531,15 @@ template struct endian_load_impl 8 -template struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; - unsigned char fill = boost::is_signed::value && ( p[6] & 0x80 )? 0xFF: 0x00; + unsigned char fill = std::is_signed::value && ( p[6] & 0x80 )? 0xFF: 0x00; tmp[0] = p[0]; tmp[1] = p[1]; @@ -557,15 +555,15 @@ template struct endian_load_impl struct endian_load_impl +template struct endian_load_impl { inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; - unsigned char fill = boost::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; + unsigned char fill = std::is_signed::value && ( p[0] & 0x80 )? 0xFF: 0x00; tmp[0] = fill; diff --git a/include/boost/endian/detail/endian_reverse.hpp b/include/boost/endian/detail/endian_reverse.hpp index 007dcd0..ce73b04 100644 --- a/include/boost/endian/detail/endian_reverse.hpp +++ b/include/boost/endian/detail/endian_reverse.hpp @@ -8,14 +8,10 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include +#include #include +#include +#include #include #include @@ -47,12 +43,12 @@ namespace detail // -- intrinsic approach suggested by reviewers, and by David Stone, who provided // his Boost licensed macro implementation (detail/intrinsic.hpp) -inline uint8_t BOOST_CONSTEXPR endian_reverse_impl( uint8_t x ) BOOST_NOEXCEPT +inline std::uint8_t BOOST_CONSTEXPR endian_reverse_impl( std::uint8_t x ) BOOST_NOEXCEPT { return x; } -inline uint16_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint16_t x ) BOOST_NOEXCEPT +inline std::uint16_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( std::uint16_t x ) BOOST_NOEXCEPT { #ifdef BOOST_ENDIAN_NO_INTRINSICS @@ -65,11 +61,11 @@ inline uint16_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint16_t x ) BOOST_N #endif } -inline uint32_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint32_t x ) BOOST_NOEXCEPT +inline std::uint32_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( std::uint32_t x ) BOOST_NOEXCEPT { #ifdef BOOST_ENDIAN_NO_INTRINSICS - uint32_t step16 = x << 16 | x >> 16; + std::uint32_t step16 = x << 16 | x >> 16; return ((step16 << 8) & 0xff00ff00) | ((step16 >> 8) & 0x00ff00ff); #else @@ -79,12 +75,12 @@ inline uint32_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint32_t x ) BOOST_N #endif } -inline uint64_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint64_t x ) BOOST_NOEXCEPT +inline std::uint64_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( std::uint64_t x ) BOOST_NOEXCEPT { #ifdef BOOST_ENDIAN_NO_INTRINSICS - uint64_t step32 = x << 32 | x >> 32; - uint64_t step16 = (step32 & 0x0000FFFF0000FFFFULL) << 16 | (step32 & 0xFFFF0000FFFF0000ULL) >> 16; + std::uint64_t step32 = x << 32 | x >> 32; + std::uint64_t step16 = (step32 & 0x0000FFFF0000FFFFULL) << 16 | (step32 & 0xFFFF0000FFFF0000ULL) >> 16; return (step16 & 0x00FF00FF00FF00FFULL) << 8 | (step16 & 0xFF00FF00FF00FF00ULL) >> 8; #else @@ -94,27 +90,27 @@ inline uint64_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint64_t x ) BOOST_N # endif } -#if defined(BOOST_HAS_INT128) +#if defined(__SIZEOF_INT128__) -inline uint128_type BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint128_type x ) BOOST_NOEXCEPT +inline __uint128_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( __uint128_t x ) BOOST_NOEXCEPT { - return endian_reverse_impl( static_cast( x >> 64 ) ) | - static_cast( endian_reverse_impl( static_cast( x ) ) ) << 64; + return endian_reverse_impl( static_cast( x >> 64 ) ) | + static_cast<__uint128_t>( endian_reverse_impl( static_cast( x ) ) ) << 64; } #endif // is_endian_reversible -template struct is_endian_reversible: boost::integral_constant::value && !boost::is_same::value) || is_scoped_enum::value> +template struct is_endian_reversible: std::integral_constant::value && !std::is_same::value) || is_scoped_enum::value> { }; // is_endian_reversible_inplace -template struct is_endian_reversible_inplace: boost::integral_constant::value || boost::is_enum::value || boost::is_same::value || boost::is_same::value> +template struct is_endian_reversible_inplace: std::integral_constant::value || std::is_enum::value || std::is_same::value || std::is_same::value> { }; @@ -124,10 +120,10 @@ template struct is_endian_reversible_inplace: boost::integral_constant< // T is non-bool integral or scoped enumeration type template inline BOOST_CONSTEXPR - typename enable_if_< !is_class::value, T >::type + typename std::enable_if< !std::is_class::value, T >::type endian_reverse( T x ) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( detail::is_endian_reversible::value ); + BOOST_ENDIAN_STATIC_ASSERT( detail::is_endian_reversible::value ); typedef typename detail::integral_by_size< sizeof(T) >::type uintN_t; @@ -138,10 +134,10 @@ template inline BOOST_CONSTEXPR // T is integral, enumeration, float or double template inline - typename enable_if_< !is_class::value >::type + typename std::enable_if< !std::is_class::value >::type endian_reverse_inplace( T & x ) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace::value ); + BOOST_ENDIAN_STATIC_ASSERT( detail::is_endian_reversible_inplace::value ); typename detail::integral_by_size< sizeof(T) >::type x2; @@ -155,7 +151,7 @@ template inline // Default implementation for user-defined types template inline - typename enable_if_< is_class::value >::type + typename std::enable_if< std::is_class::value >::type endian_reverse_inplace( T & x ) BOOST_NOEXCEPT { x = endian_reverse( x ); diff --git a/include/boost/endian/detail/endian_store.hpp b/include/boost/endian/detail/endian_store.hpp index a624352..523f039 100644 --- a/include/boost/endian/detail/endian_store.hpp +++ b/include/boost/endian/detail/endian_store.hpp @@ -10,9 +10,8 @@ #include #include #include -#include -#include -#include +#include +#include #include #include @@ -24,7 +23,7 @@ namespace endian namespace detail { -template struct endian_store_impl +template struct endian_store_impl { }; @@ -37,11 +36,11 @@ template +template inline void endian_store( unsigned char * p, T const & v ) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8 ); - BOOST_STATIC_ASSERT( N >= 1 && N <= sizeof(T) ); + BOOST_ENDIAN_STATIC_ASSERT( sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8 ); + BOOST_ENDIAN_STATIC_ASSERT( N >= 1 && N <= sizeof(T) ); return detail::endian_store_impl()( p, v ); } @@ -51,11 +50,11 @@ namespace detail // same endianness, same size -template struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_trivially_copyable::value ); + BOOST_ENDIAN_STATIC_ASSERT( is_trivially_copyable::value ); std::memcpy( p, &v, N ); } @@ -63,11 +62,11 @@ template struct endian_store // same size, reverse endianness -template struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_trivially_copyable::value ); + BOOST_ENDIAN_STATIC_ASSERT( is_trivially_copyable::value ); typename integral_by_size::type tmp; std::memcpy( &tmp, &v, N ); @@ -80,11 +79,11 @@ template 1 -template struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 2 ]; boost::endian::endian_store( tmp, v ); @@ -93,11 +92,11 @@ template struct endian_store_impl struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 2 ]; boost::endian::endian_store( tmp, v ); @@ -108,11 +107,11 @@ template struct endian_store_impl 1 -template struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 4 ]; boost::endian::endian_store( tmp, v ); @@ -121,11 +120,11 @@ template struct endian_store_impl struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 4 ]; boost::endian::endian_store( tmp, v ); @@ -136,11 +135,11 @@ template struct endian_store_impl 2 -template struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 4 ]; boost::endian::endian_store( tmp, v ); @@ -150,11 +149,11 @@ template struct endian_store_impl struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 4 ]; boost::endian::endian_store( tmp, v ); @@ -166,11 +165,11 @@ template struct endian_store_impl 3 -template struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 4 ]; boost::endian::endian_store( tmp, v ); @@ -181,11 +180,11 @@ template struct endian_store_impl struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 4 ]; boost::endian::endian_store( tmp, v ); @@ -198,11 +197,11 @@ template struct endian_store_impl 1 -template struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; boost::endian::endian_store( tmp, v ); @@ -211,11 +210,11 @@ template struct endian_store_impl struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; boost::endian::endian_store( tmp, v ); @@ -226,11 +225,11 @@ template struct endian_store_impl 2 -template struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; boost::endian::endian_store( tmp, v ); @@ -240,11 +239,11 @@ template struct endian_store_impl struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; boost::endian::endian_store( tmp, v ); @@ -256,11 +255,11 @@ template struct endian_store_impl 3 -template struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; boost::endian::endian_store( tmp, v ); @@ -271,11 +270,11 @@ template struct endian_store_impl struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; boost::endian::endian_store( tmp, v ); @@ -288,11 +287,11 @@ template struct endian_store_impl 4 -template struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; boost::endian::endian_store( tmp, v ); @@ -304,11 +303,11 @@ template struct endian_store_impl struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; boost::endian::endian_store( tmp, v ); @@ -322,11 +321,11 @@ template struct endian_store_impl 5 -template struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; boost::endian::endian_store( tmp, v ); @@ -339,11 +338,11 @@ template struct endian_store_impl struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; boost::endian::endian_store( tmp, v ); @@ -358,11 +357,11 @@ template struct endian_store_impl 6 -template struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; boost::endian::endian_store( tmp, v ); @@ -376,11 +375,11 @@ template struct endian_store_impl struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; boost::endian::endian_store( tmp, v ); @@ -396,11 +395,11 @@ template struct endian_store_impl 7 -template struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; boost::endian::endian_store( tmp, v ); @@ -415,11 +414,11 @@ template struct endian_store_impl struct endian_store_impl +template struct endian_store_impl { inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value || is_enum::value ); + BOOST_ENDIAN_STATIC_ASSERT( std::is_integral::value || std::is_enum::value ); unsigned char tmp[ 8 ]; boost::endian::endian_store( tmp, v ); diff --git a/include/boost/endian/detail/integral_by_size.hpp b/include/boost/endian/detail/integral_by_size.hpp index d53ee17..2ff2445 100644 --- a/include/boost/endian/detail/integral_by_size.hpp +++ b/include/boost/endian/detail/integral_by_size.hpp @@ -6,8 +6,7 @@ // Distributed under the Boost Software License, Version 1.0. // http://www.boost.org/LICENSE_1_0.txt -#include -#include +#include #include namespace boost @@ -23,29 +22,29 @@ template struct integral_by_size template<> struct integral_by_size<1> { - typedef uint8_t type; + typedef std::uint8_t type; }; template<> struct integral_by_size<2> { - typedef uint16_t type; + typedef std::uint16_t type; }; template<> struct integral_by_size<4> { - typedef uint32_t type; + typedef std::uint32_t type; }; template<> struct integral_by_size<8> { - typedef uint64_t type; + typedef std::uint64_t type; }; -#if defined(BOOST_HAS_INT128) +#if defined(__SIZEOF_INT128__) template<> struct integral_by_size<16> { - typedef uint128_type type; + typedef __uint128_t type; }; #endif diff --git a/include/boost/endian/detail/is_scoped_enum.hpp b/include/boost/endian/detail/is_scoped_enum.hpp index f5690a9..88bc1e8 100644 --- a/include/boost/endian/detail/is_scoped_enum.hpp +++ b/include/boost/endian/detail/is_scoped_enum.hpp @@ -6,9 +6,7 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt -#include -#include -#include +#include namespace boost { @@ -17,13 +15,13 @@ namespace endian namespace detail { -template struct negation: boost::integral_constant {}; +template struct negation: std::integral_constant {}; template struct is_scoped_enum: - boost::conditional< - boost::is_enum::value, - negation< boost::is_convertible >, - boost::false_type + std::conditional< + std::is_enum::value, + negation< std::is_convertible >, + std::false_type >::type { }; diff --git a/include/boost/endian/detail/is_trivially_copyable.hpp b/include/boost/endian/detail/is_trivially_copyable.hpp index b34f948..1a663b7 100644 --- a/include/boost/endian/detail/is_trivially_copyable.hpp +++ b/include/boost/endian/detail/is_trivially_copyable.hpp @@ -7,13 +7,7 @@ // http://www.boost.org/LICENSE_1_0.txt #include -#include -#include -#include - -#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) -# include -#endif +#include namespace boost { @@ -28,8 +22,8 @@ using std::is_trivially_copyable; #else -template struct is_trivially_copyable: boost::integral_constant::value && boost::has_trivial_assign::value && boost::has_trivial_destructor::value> {}; +template struct is_trivially_copyable: std::integral_constant::value && std::has_trivial_assign::value && std::has_trivial_destructor::value> {}; #endif diff --git a/include/boost/endian/detail/order.hpp b/include/boost/endian/detail/order.hpp index ddf4c9c..d2e1a91 100644 --- a/include/boost/endian/detail/order.hpp +++ b/include/boost/endian/detail/order.hpp @@ -6,8 +6,6 @@ // Distributed under the Boost Software License, Version 1.0. // http://www.boost.org/LICENSE_1_0.txt -#include - #if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ # define BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER little @@ -43,13 +41,12 @@ namespace boost namespace endian { -BOOST_SCOPED_ENUM_START(order) +enum class order { big, little, native = BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER - -}; BOOST_SCOPED_ENUM_END +}; } // namespace endian } // namespace boost diff --git a/include/boost/endian/detail/requires_cxx11.hpp b/include/boost/endian/detail/requires_cxx11.hpp deleted file mode 100644 index 8e4d4f7..0000000 --- a/include/boost/endian/detail/requires_cxx11.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef BOOST_ENDIAN_DETAIL_REQUIRES_CXX11_HPP_INCLUDED -#define BOOST_ENDIAN_DETAIL_REQUIRES_CXX11_HPP_INCLUDED - -// Copyright 2023 Peter Dimov -// Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt - -#include -#include - -#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || \ - defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || \ - defined(BOOST_NO_CXX11_DECLTYPE) || \ - defined(BOOST_NO_CXX11_CONSTEXPR) || \ - defined(BOOST_NO_CXX11_NOEXCEPT) || \ - defined(BOOST_NO_CXX11_SCOPED_ENUMS) || \ - defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) - -BOOST_PRAGMA_MESSAGE("C++03 support was deprecated in Boost.Endian 1.82 and will be removed in Boost.Endian 1.84. Please open an issue in https://github.com/boostorg/endian if you want it retained.") - -#endif - -#endif // #ifndef BOOST_ENDIAN_DETAIL_REQUIRES_CXX11_HPP_INCLUDED diff --git a/include/boost/endian/detail/static_assert.hpp b/include/boost/endian/detail/static_assert.hpp new file mode 100644 index 0000000..5b89b4f --- /dev/null +++ b/include/boost/endian/detail/static_assert.hpp @@ -0,0 +1,10 @@ +#ifndef BOOST_ENDIAN_DETAIL_STATIC_ASSERT_HPP_INCLUDED +#define BOOST_ENDIAN_DETAIL_STATIC_ASSERT_HPP_INCLUDED + +// Copyright 2023 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#define BOOST_ENDIAN_STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +#endif // BOOST_ENDIAN_DETAIL_STATIC_ASSERT_HPP_INCLUDED diff --git a/include/boost/endian/endian.hpp b/include/boost/endian/endian.hpp index 06b607b..655d05a 100644 --- a/include/boost/endian/endian.hpp +++ b/include/boost/endian/endian.hpp @@ -29,8 +29,8 @@ namespace endian typedef align alignment; # ifndef BOOST_NO_CXX11_TEMPLATE_ALIASES - template + template using endian = endian_arithmetic; # endif diff --git a/test/conversion_test.cpp b/test/conversion_test.cpp index f9bb7bd..2828890 100644 --- a/test/conversion_test.cpp +++ b/test/conversion_test.cpp @@ -29,14 +29,14 @@ namespace be = boost::endian; using std::cout; using std::endl; -using boost::int8_t; -using boost::uint8_t; -using boost::int16_t; -using boost::uint16_t; -using boost::int32_t; -using boost::uint32_t; -using boost::int64_t; -using boost::uint64_t; +using std::int8_t; +using std::uint8_t; +using std::int16_t; +using std::uint16_t; +using std::int32_t; +using std::uint32_t; +using std::int64_t; +using std::uint64_t; template inline T std_endian_reverse(T x) BOOST_NOEXCEPT { diff --git a/test/endian_arithmetic_test.cpp b/test/endian_arithmetic_test.cpp index 725aac2..a3b78e0 100644 --- a/test/endian_arithmetic_test.cpp +++ b/test/endian_arithmetic_test.cpp @@ -9,7 +9,7 @@ #include #include -template void test_arithmetic_( T const& x ) +template void test_arithmetic_( T const& x ) { boost::endian::endian_arithmetic y( x ); @@ -78,7 +78,7 @@ template void test_integral_( T const& x ) +template void test_integral_( T const& x ) { boost::endian::endian_arithmetic y( x ); diff --git a/test/endian_reverse_test.cpp b/test/endian_reverse_test.cpp index fa0f907..ed2aaf3 100644 --- a/test/endian_reverse_test.cpp +++ b/test/endian_reverse_test.cpp @@ -176,17 +176,17 @@ template void test_np() int main() { - test(); - test(); + test(); + test(); - test(); - test(); + test(); + test(); - test(); - test(); + test(); + test(); - test(); - test(); + test(); + test(); test(); test();