conversion.hpp: remove unused detail functions, static-assert that types are EndianReversible

This commit is contained in:
Peter Dimov
2019-04-29 01:32:07 +03:00
parent b29b3dfc10
commit f0f8e398d6
2 changed files with 220 additions and 198 deletions
+10 -2
View File
@@ -14,6 +14,7 @@
#include <boost/core/lightweight_test.hpp>
#include <iostream>
#include <cstring>
#include <algorithm>
namespace be = boost::endian;
using std::cout;
@@ -27,6 +28,13 @@ using boost::uint32_t;
using boost::int64_t;
using boost::uint64_t;
template <class T> inline T std_endian_reverse(T x) BOOST_NOEXCEPT
{
T tmp(x);
std::reverse( reinterpret_cast<unsigned char*>(&tmp), reinterpret_cast<unsigned char*>(&tmp) + sizeof(T) );
return tmp;
}
namespace
{
@@ -102,9 +110,9 @@ namespace
# if BOOST_ENDIAN_BIG_BYTE
BOOST_TEST_EQ(native, big);
BOOST_TEST_EQ(be::detail::std_endian_reverse(native), little);
BOOST_TEST_EQ(::std_endian_reverse(native), little);
# else
BOOST_TEST_EQ(be::detail::std_endian_reverse(native), big);
BOOST_TEST_EQ(::std_endian_reverse(native), big);
BOOST_TEST_EQ(native, little);
# endif