From b8139ad7a1e0e6b68f69a5ace0608ac7ba3a5ba6 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 4 Jan 2020 21:18:35 +0200 Subject: [PATCH] Remove use of Predef in arithmetic.hpp, buffers.hpp, conversion.hpp --- include/boost/endian/arithmetic.hpp | 55 ++++---------- include/boost/endian/buffers.hpp | 55 ++++---------- include/boost/endian/conversion.hpp | 111 +++------------------------- 3 files changed, 41 insertions(+), 180 deletions(-) diff --git a/include/boost/endian/arithmetic.hpp b/include/boost/endian/arithmetic.hpp index eb68a77..a31c2eb 100644 --- a/include/boost/endian/arithmetic.hpp +++ b/include/boost/endian/arithmetic.hpp @@ -29,7 +29,6 @@ #include #include -#include #include #include #include @@ -146,47 +145,25 @@ namespace endian typedef endian_arithmetic little_uint56_t; typedef endian_arithmetic little_uint64_t; -# if BOOST_ENDIAN_BIG_BYTE // native endian signed integer unaligned types - typedef big_int8_t native_int8_t; - typedef big_int16_t native_int16_t; - typedef big_int24_t native_int24_t; - typedef big_int32_t native_int32_t; - typedef big_int40_t native_int40_t; - typedef big_int48_t native_int48_t; - typedef big_int56_t native_int56_t; - typedef big_int64_t 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 big_uint8_t native_uint8_t; - typedef big_uint16_t native_uint16_t; - typedef big_uint24_t native_uint24_t; - typedef big_uint32_t native_uint32_t; - typedef big_uint40_t native_uint40_t; - typedef big_uint48_t native_uint48_t; - typedef big_uint56_t native_uint56_t; - typedef big_uint64_t native_uint64_t; -# else - // native endian signed integer unaligned types - typedef little_int8_t native_int8_t; - typedef little_int16_t native_int16_t; - typedef little_int24_t native_int24_t; - typedef little_int32_t native_int32_t; - typedef little_int40_t native_int40_t; - typedef little_int48_t native_int48_t; - typedef little_int56_t native_int56_t; - typedef little_int64_t native_int64_t; - - // native endian unsigned integer unaligned types - typedef little_uint8_t native_uint8_t; - typedef little_uint16_t native_uint16_t; - typedef little_uint24_t native_uint24_t; - typedef little_uint32_t native_uint32_t; - typedef little_uint40_t native_uint40_t; - typedef little_uint48_t native_uint48_t; - typedef little_uint56_t native_uint56_t; - typedef little_uint64_t native_uint64_t; -# endif + 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; diff --git a/include/boost/endian/buffers.hpp b/include/boost/endian/buffers.hpp index 856dbca..459e66f 100644 --- a/include/boost/endian/buffers.hpp +++ b/include/boost/endian/buffers.hpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -149,47 +148,25 @@ namespace endian typedef endian_buffer little_uint56_buf_t; typedef endian_buffer little_uint64_buf_t; -# if BOOST_ENDIAN_BIG_BYTE // unaligned native endian signed integer buffers - typedef big_int8_buf_t native_int8_buf_t; - typedef big_int16_buf_t native_int16_buf_t; - typedef big_int24_buf_t native_int24_buf_t; - typedef big_int32_buf_t native_int32_buf_t; - typedef big_int40_buf_t native_int40_buf_t; - typedef big_int48_buf_t native_int48_buf_t; - typedef big_int56_buf_t native_int56_buf_t; - typedef big_int64_buf_t 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 big_uint8_buf_t native_uint8_buf_t; - typedef big_uint16_buf_t native_uint16_buf_t; - typedef big_uint24_buf_t native_uint24_buf_t; - typedef big_uint32_buf_t native_uint32_buf_t; - typedef big_uint40_buf_t native_uint40_buf_t; - typedef big_uint48_buf_t native_uint48_buf_t; - typedef big_uint56_buf_t native_uint56_buf_t; - typedef big_uint64_buf_t native_uint64_buf_t; -# else - // unaligned native endian signed integer buffers - typedef little_int8_buf_t native_int8_buf_t; - typedef little_int16_buf_t native_int16_buf_t; - typedef little_int24_buf_t native_int24_buf_t; - typedef little_int32_buf_t native_int32_buf_t; - typedef little_int40_buf_t native_int40_buf_t; - typedef little_int48_buf_t native_int48_buf_t; - typedef little_int56_buf_t native_int56_buf_t; - typedef little_int64_buf_t native_int64_buf_t; - - // unaligned native endian unsigned integer buffers - typedef little_uint8_buf_t native_uint8_buf_t; - typedef little_uint16_buf_t native_uint16_buf_t; - typedef little_uint24_buf_t native_uint24_buf_t; - typedef little_uint32_buf_t native_uint32_buf_t; - typedef little_uint40_buf_t native_uint40_buf_t; - typedef little_uint48_buf_t native_uint48_buf_t; - typedef little_uint56_buf_t native_uint56_buf_t; - typedef little_uint64_buf_t native_uint64_buf_t; -# endif + 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; diff --git a/include/boost/endian/conversion.hpp b/include/boost/endian/conversion.hpp index ce8a103..e03c827 100644 --- a/include/boost/endian/conversion.hpp +++ b/include/boost/endian/conversion.hpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -156,65 +155,25 @@ template struct is_endian_reversible: boost::integral_constant inline BOOST_CONSTEXPR EndianReversible big_to_native( EndianReversible x ) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( detail::is_endian_reversible::value ); - -#if BOOST_ENDIAN_BIG_BYTE - - return x; - -#else - - return endian_reverse(x); - -#endif - } + return boost::endian::conditional_reverse( x ); +} template inline BOOST_CONSTEXPR EndianReversible native_to_big( EndianReversible x ) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( detail::is_endian_reversible::value ); - -#if BOOST_ENDIAN_BIG_BYTE - - return x; - -#else - - return endian_reverse(x); - -#endif + return boost::endian::conditional_reverse( x ); } template inline BOOST_CONSTEXPR EndianReversible little_to_native( EndianReversible x ) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( detail::is_endian_reversible::value ); - -#if BOOST_ENDIAN_LITTLE_BYTE - - return x; - -#else - - return endian_reverse(x); - -#endif + return boost::endian::conditional_reverse( x ); } template inline BOOST_CONSTEXPR EndianReversible native_to_little( EndianReversible x ) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( detail::is_endian_reversible::value ); - -#if BOOST_ENDIAN_LITTLE_BYTE - - return x; - -#else - - return endian_reverse(x); - -#endif + return boost::endian::conditional_reverse( x ); } namespace detail @@ -265,82 +224,30 @@ template struct is_endian_reversible_inplace: boost::integral_constant< } // namespace detail -#if BOOST_ENDIAN_BIG_BYTE - -template -inline void big_to_native_inplace( EndianReversibleInplace& ) BOOST_NOEXCEPT -{ - BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace::value ); -} - -#else - template inline void big_to_native_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace::value ); - endian_reverse_inplace( x ); + boost::endian::conditional_reverse_inplace( x ); } -#endif - -#if BOOST_ENDIAN_BIG_BYTE - -template -inline void native_to_big_inplace( EndianReversibleInplace& ) BOOST_NOEXCEPT -{ - BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace::value ); -} - -#else - template inline void native_to_big_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace::value ); - endian_reverse_inplace( x ); + boost::endian::conditional_reverse_inplace( x ); } -#endif - -#if BOOST_ENDIAN_LITTLE_BYTE - -template -inline void little_to_native_inplace( EndianReversibleInplace& ) BOOST_NOEXCEPT -{ - BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace::value ); -} - -#else - template inline void little_to_native_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace::value ); - endian_reverse_inplace( x ); + boost::endian::conditional_reverse_inplace( x ); } -#endif - -#if BOOST_ENDIAN_LITTLE_BYTE - -template -inline void native_to_little_inplace( EndianReversibleInplace& ) BOOST_NOEXCEPT -{ - BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace::value ); -} - -#else - template inline void native_to_little_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace::value ); - endian_reverse_inplace( x ); + boost::endian::conditional_reverse_inplace( x ); } -#endif - namespace detail {