forked from boostorg/endian
Move is_endian_reversible, is_endian_reversible_inplace to detail/endian_reverse.hpp
This commit is contained in:
@ -13,8 +13,6 @@
|
||||
#include <boost/endian/detail/endian_store.hpp>
|
||||
#include <boost/endian/detail/order.hpp>
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
@ -145,16 +143,6 @@ namespace endian
|
||||
|
||||
//----------------------------------- end synopsis -------------------------------------//
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class T> struct is_endian_reversible: boost::integral_constant<bool,
|
||||
boost::is_class<T>::value || ( boost::is_integral<T>::value && !boost::is_same<T, bool>::value )>
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <class EndianReversible>
|
||||
inline BOOST_CONSTEXPR EndianReversible big_to_native( EndianReversible x ) BOOST_NOEXCEPT
|
||||
{
|
||||
@ -200,7 +188,7 @@ inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversib
|
||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class EndianReversible>
|
||||
inline BOOST_CONSTEXPR EndianReversible conditional_reverse( EndianReversible x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( detail::is_endian_reversible<EndianReversible>::value );
|
||||
BOOST_STATIC_ASSERT( boost::is_class<EndianReversible>::value || detail::is_endian_reversible<EndianReversible>::value );
|
||||
return detail::conditional_reverse_impl( x, boost::integral_constant<bool, From == To>() );
|
||||
}
|
||||
|
||||
@ -209,7 +197,7 @@ template <class EndianReversible>
|
||||
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<EndianReversible>::value );
|
||||
BOOST_STATIC_ASSERT( boost::is_class<EndianReversible>::value || detail::is_endian_reversible<EndianReversible>::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<class T> struct is_endian_reversible_inplace: boost::integral_constant<bool,
|
||||
boost::is_class<T>::value || ( boost::is_integral<T>::value && !boost::is_same<T, bool>::value )>
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <class EndianReversibleInplace>
|
||||
inline void big_to_native_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
|
||||
{
|
||||
@ -271,7 +249,7 @@ inline void conditional_reverse_inplace_impl( EndianReversibleInplace& x, boost:
|
||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class EndianReversibleInplace>
|
||||
inline void conditional_reverse_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
|
||||
BOOST_STATIC_ASSERT( boost::is_class<EndianReversibleInplace>::value || detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
|
||||
detail::conditional_reverse_inplace_impl( x, boost::integral_constant<bool, From == To>() );
|
||||
}
|
||||
|
||||
@ -280,7 +258,7 @@ template <class EndianReversibleInplace>
|
||||
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<EndianReversibleInplace>::value );
|
||||
BOOST_STATIC_ASSERT( boost::is_class<EndianReversibleInplace>::value || detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
|
||||
|
||||
if( from_order != to_order )
|
||||
{
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/enable_if.hpp>
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/config.hpp>
|
||||
@ -103,6 +104,20 @@ inline uint128_type BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint128_type x )
|
||||
|
||||
#endif
|
||||
|
||||
// is_endian_reversible
|
||||
|
||||
template<class T> struct is_endian_reversible: boost::integral_constant<bool,
|
||||
boost::is_integral<T>::value && !boost::is_same<T, bool>::value>
|
||||
{
|
||||
};
|
||||
|
||||
// is_endian_reversible_inplace
|
||||
|
||||
template<class T> struct is_endian_reversible_inplace: boost::integral_constant<bool,
|
||||
boost::is_integral<T>::value && !boost::is_same<T, bool>::value>
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
// Requires:
|
||||
@ -112,7 +127,7 @@ template<class T> inline BOOST_CONSTEXPR
|
||||
typename enable_if_< !is_class<T>::value, T >::type
|
||||
endian_reverse( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value && !(is_same<T, bool>::value) );
|
||||
BOOST_STATIC_ASSERT( detail::is_endian_reversible<T>::value );
|
||||
|
||||
typedef typename detail::integral_by_size< sizeof(T) >::type uintN_t;
|
||||
|
||||
@ -122,6 +137,7 @@ template<class T> inline BOOST_CONSTEXPR
|
||||
template <class EndianReversible>
|
||||
inline void endian_reverse_inplace(EndianReversible& x) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( boost::is_class<EndianReversible>::value || detail::is_endian_reversible_inplace<EndianReversible>::value );
|
||||
x = endian_reverse( x );
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user