diff --git a/endian.hpp b/endian.hpp index d23319d4..a61ca2d8 100644 --- a/endian.hpp +++ b/endian.hpp @@ -17,15 +17,10 @@ namespace cruft { //------------------------------------------------------------------------- - template - constexpr T - bswap (T) noexcept; - // CXX: Update using "if constexpr" when available. It doesn't seem to be // worth the dicking about to use enable_if_t to differentiate the // signed/unsigned cases. #define SIGNED_BSWAP(S) \ - template <> \ constexpr \ int##S##_t \ bswap (int##S##_t v) noexcept { \ @@ -41,12 +36,12 @@ namespace cruft { SIGNED_BSWAP(32) SIGNED_BSWAP(64) - template <> constexpr int8_t bswap ( int8_t v) noexcept { return v; } - template <> constexpr uint8_t bswap (uint8_t v) noexcept { return v; } + constexpr int8_t bswap ( int8_t v) noexcept { return v; } + constexpr uint8_t bswap (uint8_t v) noexcept { return v; } - template <> constexpr uint16_t bswap (uint16_t v) noexcept { return __builtin_bswap16 (v); } - template <> constexpr uint32_t bswap (uint32_t v) noexcept { return __builtin_bswap32 (v); } - template <> constexpr uint64_t bswap (uint64_t v) noexcept { return __builtin_bswap64 (v); } + constexpr uint16_t bswap (uint16_t v) noexcept { return __builtin_bswap16 (v); } + constexpr uint32_t bswap (uint32_t v) noexcept { return __builtin_bswap32 (v); } + constexpr uint64_t bswap (uint64_t v) noexcept { return __builtin_bswap64 (v); } // use a type-punning union to punt the byte swapping operation to the @@ -54,7 +49,6 @@ namespace cruft { // // this is debatably safe under production compilers like gcc + clang // despite what the standard may say about unions. - template <> constexpr float bswap (float v) noexcept {