From 74b73c5c038eaec37bd159c8ef846c2f9bba56e6 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 2 May 2020 22:15:08 +0300 Subject: [PATCH] Move is_endian_reversible, is_endian_reversible_inplace to detail/endian_reverse.hpp --- include/boost/endian/conversion.hpp | 30 +++---------------- .../boost/endian/detail/endian_reverse.hpp | 18 ++++++++++- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/include/boost/endian/conversion.hpp b/include/boost/endian/conversion.hpp index 8c11cbb..58aaa4a 100644 --- a/include/boost/endian/conversion.hpp +++ b/include/boost/endian/conversion.hpp @@ -13,8 +13,6 @@ #include #include #include -#include -#include #include #include #include @@ -145,16 +143,6 @@ namespace endian //----------------------------------- end synopsis -------------------------------------// -namespace detail -{ - -template struct is_endian_reversible: boost::integral_constant::value || ( boost::is_integral::value && !boost::is_same::value )> -{ -}; - -} // namespace detail - template inline BOOST_CONSTEXPR EndianReversible big_to_native( EndianReversible x ) BOOST_NOEXCEPT { @@ -200,7 +188,7 @@ inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversib template inline BOOST_CONSTEXPR EndianReversible conditional_reverse( EndianReversible x ) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( detail::is_endian_reversible::value ); + BOOST_STATIC_ASSERT( boost::is_class::value || detail::is_endian_reversible::value ); return detail::conditional_reverse_impl( x, boost::integral_constant() ); } @@ -209,7 +197,7 @@ template inline BOOST_CONSTEXPR EndianReversible conditional_reverse( EndianReversible x, BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order ) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( detail::is_endian_reversible::value ); + BOOST_STATIC_ASSERT( boost::is_class::value || detail::is_endian_reversible::value ); return from_order == to_order? x: endian_reverse( x ); } @@ -217,16 +205,6 @@ inline BOOST_CONSTEXPR EndianReversible conditional_reverse( EndianReversible x, // reverse-in-place implementation // //--------------------------------------------------------------------------------------// -namespace detail -{ - -template struct is_endian_reversible_inplace: boost::integral_constant::value || ( boost::is_integral::value && !boost::is_same::value )> -{ -}; - -} // namespace detail - template inline void big_to_native_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT { @@ -271,7 +249,7 @@ inline void conditional_reverse_inplace_impl( EndianReversibleInplace& x, boost: template inline void conditional_reverse_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace::value ); + BOOST_STATIC_ASSERT( boost::is_class::value || detail::is_endian_reversible_inplace::value ); detail::conditional_reverse_inplace_impl( x, boost::integral_constant() ); } @@ -280,7 +258,7 @@ template inline void conditional_reverse_inplace( EndianReversibleInplace& x, BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order ) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace::value ); + BOOST_STATIC_ASSERT( boost::is_class::value || detail::is_endian_reversible_inplace::value ); if( from_order != to_order ) { diff --git a/include/boost/endian/detail/endian_reverse.hpp b/include/boost/endian/detail/endian_reverse.hpp index 2033fca..74e59e6 100644 --- a/include/boost/endian/detail/endian_reverse.hpp +++ b/include/boost/endian/detail/endian_reverse.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -103,6 +104,20 @@ inline uint128_type BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint128_type x ) #endif +// is_endian_reversible + +template struct is_endian_reversible: boost::integral_constant::value && !boost::is_same::value> +{ +}; + +// is_endian_reversible_inplace + +template struct is_endian_reversible_inplace: boost::integral_constant::value && !boost::is_same::value> +{ +}; + } // namespace detail // Requires: @@ -112,7 +127,7 @@ template inline BOOST_CONSTEXPR typename enable_if_< !is_class::value, T >::type endian_reverse( T x ) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT( is_integral::value && !(is_same::value) ); + BOOST_STATIC_ASSERT( detail::is_endian_reversible::value ); typedef typename detail::integral_by_size< sizeof(T) >::type uintN_t; @@ -122,6 +137,7 @@ template inline BOOST_CONSTEXPR template inline void endian_reverse_inplace(EndianReversible& x) BOOST_NOEXCEPT { + BOOST_STATIC_ASSERT( boost::is_class::value || detail::is_endian_reversible_inplace::value ); x = endian_reverse( x ); }