mirror of
https://github.com/boostorg/endian.git
synced 2025-08-02 14:04:29 +02:00
Use detail::reverse_value() to implement reverse_value() for float and double, thus eliminating type-punning warning from gcc.
This commit is contained in:
@@ -236,16 +236,14 @@ namespace endian
|
|||||||
{
|
{
|
||||||
BOOST_STATIC_ASSERT_MSG(sizeof(float) == sizeof(uint32_t),
|
BOOST_STATIC_ASSERT_MSG(sizeof(float) == sizeof(uint32_t),
|
||||||
"boost::endian only supprts sizeof(float) == 4; please report error to boost mailing list");
|
"boost::endian only supprts sizeof(float) == 4; please report error to boost mailing list");
|
||||||
uint32_t tmp = reverse_value(*(const uint32_t*)&x);
|
return detail::reverse_value(x);
|
||||||
return *(const float*)&tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double reverse_value(double x) BOOST_NOEXCEPT
|
inline double reverse_value(double x) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
BOOST_STATIC_ASSERT_MSG(sizeof(double) == sizeof(uint64_t),
|
BOOST_STATIC_ASSERT_MSG(sizeof(double) == sizeof(uint64_t),
|
||||||
"boost::endian only supprts sizeof(double) == 8; please report error to boost mailing list");
|
"boost::endian only supprts sizeof(double) == 8; please report error to boost mailing list");
|
||||||
uint64_t tmp = reverse_value(*(const uint64_t*)&x);
|
return detail::reverse_value(x);
|
||||||
return *(const double*)&tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
|
Reference in New Issue
Block a user