utils/endian.hpp: Use std::byteswap

This commit is contained in:
Eladash 2023-08-17 11:02:40 +03:00 committed by Elad Ashkenazi
parent 6adc7f9ee6
commit dacb0bd87f

View file

@ -35,7 +35,9 @@ namespace stx
static constexpr u16 swap(u16 src) noexcept
{
#if defined(__GNUG__)
#if __cpp_lib_byteswap >= 202110L
return std::byteswap(src);
#elif defined(__GNUG__)
return __builtin_bswap16(src);
#else
if (std::is_constant_evaluated())
@ -55,7 +57,9 @@ namespace stx
static constexpr u32 swap(u32 src) noexcept
{
#if defined(__GNUG__)
#if __cpp_lib_byteswap >= 202110L
return std::byteswap(src);
#elif defined(__GNUG__)
return __builtin_bswap32(src);
#else
if (std::is_constant_evaluated())
@ -76,7 +80,9 @@ namespace stx
static constexpr u64 swap(u64 src) noexcept
{
#if defined(__GNUG__)
#if __cpp_lib_byteswap >= 202110L
return std::byteswap(src);
#elif defined(__GNUG__)
return __builtin_bswap64(src);
#else
if (std::is_constant_evaluated())