diff --git a/include/boost/endian/conversion.hpp b/include/boost/endian/conversion.hpp index bd5e7fc..bd4d682 100644 --- a/include/boost/endian/conversion.hpp +++ b/include/boost/endian/conversion.hpp @@ -174,6 +174,35 @@ namespace endian //----------------------------------- end synopsis -------------------------------------// + namespace detail + { + // generic reverse function template implementation approach using std::reverse + // suggested by Mathias Gaunard. Primary motivation for inclusion is to have an + // independent implementation to test against. Secondary motivation is use by + // floating-point reverse_endianness, but that use is likely to be replace by a + // more tailored floating-point implementation. + + template + inline T std_reverse_endianness(T x) BOOST_NOEXCEPT + { + T tmp(x); + std::reverse( + reinterpret_cast(&tmp), + reinterpret_cast(&tmp) + sizeof(T)); + return tmp; + } + + // conditional unaligned reverse copy, patterned after std::reverse_copy + template + inline void big_reverse_copy(T from, char* to) BOOST_NOEXCEPT; + template + inline void big_reverse_copy(const char* from, T& to) BOOST_NOEXCEPT; + template + inline void little_reverse_copy(T from, char* to) BOOST_NOEXCEPT; + template + inline void little_reverse_copy(const char* from, T& to) BOOST_NOEXCEPT; + } // namespace detail + //--------------------------------------------------------------------------------------// // // // return-by-value implementation // @@ -270,35 +299,6 @@ namespace endian # endif } - namespace detail - { - // generic reverse function template implementation approach using std::reverse - // suggested by Mathias Gaunard. Primary motivation for inclusion is to have an - // independent implementation to test against. Secondary motivation is use by - // floating-point reverse_endianness, but that use is likely to be replace by a - // more tailored floating-point implementation. - - template - inline T std_reverse_endianness(T x) BOOST_NOEXCEPT - { - T tmp(x); - std::reverse( - reinterpret_cast(&tmp), - reinterpret_cast(&tmp) + sizeof(T)); - return tmp; - } - - // conditional unaligned reverse copy, patterned after std::reverse_copy - template - inline void big_reverse_copy(T from, char* to) BOOST_NOEXCEPT; - template - inline void big_reverse_copy(const char* from, T& to) BOOST_NOEXCEPT; - template - inline void little_reverse_copy(T from, char* to) BOOST_NOEXCEPT; - template - inline void little_reverse_copy(const char* from, T& to) BOOST_NOEXCEPT; - } // namespace detail - inline float reverse_endianness(float x) BOOST_NOEXCEPT { BOOST_STATIC_ASSERT_MSG(sizeof(float) == sizeof(uint32_t), @@ -534,17 +534,6 @@ namespace endian namespace detail { - // general reverse_value function template implementation approach using std::reverse - // suggested by Mathias Gaunard - template - inline T reverse_value(T x) BOOST_NOEXCEPT - { - T tmp(x); - std::reverse( - reinterpret_cast(&tmp), - reinterpret_cast(&tmp) + sizeof(T)); - return tmp; - } template inline void big_reverse_copy(T from, char* to) BOOST_NOEXCEPT {