forked from boostorg/endian
Constrain the primary endian_reverse to not apply to class types; add test. Fixes #41.
This commit is contained in:
1 parent
3d053160ce
commit
69c020ea8f
4 files changed
+53
-5
No files matched your search
@@ -46,7 +46,8 @@ namespace endian
|
||||
// reverse byte order
|
||||
// requires T to be a non-bool integral type
|
||||
// in detail/endian_reverse.hpp
|
||||
template<class T> inline BOOST_CONSTEXPR T endian_reverse( T x ) BOOST_NOEXCEPT;
|
||||
//
|
||||
// template<class T> inline BOOST_CONSTEXPR T endian_reverse( T x ) BOOST_NOEXCEPT;
|
||||
|
||||
// reverse byte order unless native endianness is big
|
||||
template <class EndianReversible >
|
||||
@@ -109,9 +110,11 @@ namespace endian
|
||||
|
||||
// reverse in place
|
||||
// in detail/endian_reverse.hpp
|
||||
template <class EndianReversible>
|
||||
inline void endian_reverse_inplace(EndianReversible& x) BOOST_NOEXCEPT;
|
||||
// Effects: x = endian_reverse(x)
|
||||
//
|
||||
// template <class EndianReversible>
|
||||
// inline void endian_reverse_inplace(EndianReversible& x) BOOST_NOEXCEPT;
|
||||
//
|
||||
// Effects: x = endian_reverse(x)
|
||||
|
||||
// reverse in place unless native endianness is big
|
||||
template <class EndianReversibleInplace>
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <boost/endian/detail/intrinsic.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/enable_if.hpp>
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/config.hpp>
|
||||
@@ -106,7 +108,9 @@ inline uint128_type BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint128_type x )
|
||||
// Requires:
|
||||
// T is non-bool integral
|
||||
|
||||
template<class T> inline BOOST_CONSTEXPR T endian_reverse( T x ) BOOST_NOEXCEPT
|
||||
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) );
|
||||
|
||||
|
||||
Reference in new issue
Block a user