mirror of
https://github.com/boostorg/endian.git
synced 2025-08-02 05:54:31 +02:00
Add overloads for int8_t and uint8_t (rational: useful with generic programming). Template the reverse function (same body in each overloads).
This commit is contained in:
@@ -35,9 +35,11 @@ namespace endian
|
|||||||
|
|
||||||
// reverse byte order (i.e. endianness)
|
// reverse byte order (i.e. endianness)
|
||||||
//
|
//
|
||||||
|
inline int8_t reverse_value(int8_t x) BOOST_NOEXCEPT;
|
||||||
inline int16_t reverse_value(int16_t x) BOOST_NOEXCEPT;
|
inline int16_t reverse_value(int16_t x) BOOST_NOEXCEPT;
|
||||||
inline int32_t reverse_value(int32_t x) BOOST_NOEXCEPT;
|
inline int32_t reverse_value(int32_t x) BOOST_NOEXCEPT;
|
||||||
inline int64_t reverse_value(int64_t x) BOOST_NOEXCEPT;
|
inline int64_t reverse_value(int64_t x) BOOST_NOEXCEPT;
|
||||||
|
inline uint8_t reverse_value(uint8_t x) BOOST_NOEXCEPT;
|
||||||
inline uint16_t reverse_value(uint16_t x) BOOST_NOEXCEPT;
|
inline uint16_t reverse_value(uint16_t x) BOOST_NOEXCEPT;
|
||||||
inline uint32_t reverse_value(uint32_t x) BOOST_NOEXCEPT;
|
inline uint32_t reverse_value(uint32_t x) BOOST_NOEXCEPT;
|
||||||
inline uint64_t reverse_value(uint64_t x) BOOST_NOEXCEPT;
|
inline uint64_t reverse_value(uint64_t x) BOOST_NOEXCEPT;
|
||||||
@@ -87,14 +89,8 @@ namespace endian
|
|||||||
|
|
||||||
// reverse byte order (i.e. endianness)
|
// reverse byte order (i.e. endianness)
|
||||||
//
|
//
|
||||||
inline void reverse(int16_t& x) BOOST_NOEXCEPT;
|
template <class Value>
|
||||||
inline void reverse(int32_t& x) BOOST_NOEXCEPT;
|
inline void reverse(Value& x) BOOST_NOEXCEPT;
|
||||||
inline void reverse(int64_t& x) BOOST_NOEXCEPT;
|
|
||||||
inline void reverse(uint16_t& x) BOOST_NOEXCEPT;
|
|
||||||
inline void reverse(uint32_t& x) BOOST_NOEXCEPT;
|
|
||||||
inline void reverse(uint64_t& x) BOOST_NOEXCEPT;
|
|
||||||
inline void reverse(float& x) BOOST_NOEXCEPT;
|
|
||||||
inline void reverse(double& x) BOOST_NOEXCEPT;
|
|
||||||
|
|
||||||
// reverse unless native endianness is big
|
// reverse unless native endianness is big
|
||||||
template <class Reversible>
|
template <class Reversible>
|
||||||
@@ -158,6 +154,11 @@ namespace endian
|
|||||||
// //
|
// //
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
inline int8_t reverse_value(int8_t x) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
inline int16_t reverse_value(int16_t x) BOOST_NOEXCEPT
|
inline int16_t reverse_value(int16_t x) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||||
@@ -195,6 +196,11 @@ namespace endian
|
|||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline uint8_t reverse_value(uint8_t x) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
inline uint16_t reverse_value(uint16_t x) BOOST_NOEXCEPT
|
inline uint16_t reverse_value(uint16_t x) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||||
@@ -379,14 +385,8 @@ namespace endian
|
|||||||
|
|
||||||
// reverse byte order (i.e. endianness)
|
// reverse byte order (i.e. endianness)
|
||||||
//
|
//
|
||||||
inline void reverse(int16_t& x) BOOST_NOEXCEPT {x = reverse_value(x);}
|
template <class Value>
|
||||||
inline void reverse(int32_t& x) BOOST_NOEXCEPT {x = reverse_value(x);}
|
inline void reverse(Value& x) BOOST_NOEXCEPT {x = reverse_value(x);}
|
||||||
inline void reverse(int64_t& x) BOOST_NOEXCEPT {x = reverse_value(x);}
|
|
||||||
inline void reverse(uint16_t& x) BOOST_NOEXCEPT {x = reverse_value(x);}
|
|
||||||
inline void reverse(uint32_t& x) BOOST_NOEXCEPT {x = reverse_value(x);}
|
|
||||||
inline void reverse(uint64_t& x) BOOST_NOEXCEPT {x = reverse_value(x);}
|
|
||||||
inline void reverse(float& x) BOOST_NOEXCEPT {x = reverse_value(x);}
|
|
||||||
inline void reverse(double& x) BOOST_NOEXCEPT {x = reverse_value(x);}
|
|
||||||
|
|
||||||
// reverse unless native endianness is big
|
// reverse unless native endianness is big
|
||||||
template <class Reversible>
|
template <class Reversible>
|
||||||
|
Reference in New Issue
Block a user