diff --git a/include/bitsery/details/adapter_common.h b/include/bitsery/details/adapter_common.h index 7f665d4..7a77e4a 100644 --- a/include/bitsery/details/adapter_common.h +++ b/include/bitsery/details/adapter_common.h @@ -194,10 +194,11 @@ getSystemEndianness() : EndiannessType::BigEndian; } -template +template using ShouldSwap = std::integral_constant; + Config::Endianness != details::getSystemEndianness() && + sizeof(T) != 1>; /** * helper types to work with bits @@ -287,7 +288,7 @@ struct OutputAdapterBaseCRTP { static_assert(std::is_integral(), ""); static_assert(sizeof(T) == SIZE, ""); - writeSwappedValue(&v, ShouldSwap{}); + writeSwappedValue(&v, ShouldSwap{}); } template @@ -295,7 +296,7 @@ struct OutputAdapterBaseCRTP { static_assert(std::is_integral(), ""); static_assert(sizeof(T) == SIZE, ""); - writeSwappedBuffer(buf, count, ShouldSwap{}); + writeSwappedBuffer(buf, count, ShouldSwap{}); } template @@ -360,7 +361,7 @@ struct InputAdapterBaseCRTP static_assert(sizeof(T) == SIZE, ""); static_cast(this)->template readInternalValue( reinterpret_cast(&v)); - swapDataBits(v, ShouldSwap{}); + swapDataBits(v, ShouldSwap{}); } template @@ -370,7 +371,7 @@ struct InputAdapterBaseCRTP static_assert(sizeof(T) == SIZE, ""); static_cast(this)->readInternalBuffer( reinterpret_cast(buf), sizeof(T) * count); - swapDataBits(buf, count, ShouldSwap{}); + swapDataBits(buf, count, ShouldSwap{}); } template