Changes the code path for arrays of bytes in big (#105)

Thanks for PR!
This commit is contained in:
SoftdriveFelix
2023-05-09 01:47:18 -04:00
committed by GitHub
parent 90243480ec
commit ceeb189c8b

View File

@@ -194,10 +194,11 @@ getSystemEndianness()
: EndiannessType::BigEndian;
}
template<typename Config>
template<typename Config, typename T>
using ShouldSwap =
std::integral_constant<bool,
Config::Endianness != details::getSystemEndianness()>;
Config::Endianness != details::getSystemEndianness() &&
sizeof(T) != 1>;
/**
* helper types to work with bits
@@ -287,7 +288,7 @@ struct OutputAdapterBaseCRTP
{
static_assert(std::is_integral<T>(), "");
static_assert(sizeof(T) == SIZE, "");
writeSwappedValue(&v, ShouldSwap<typename Adapter::TConfig>{});
writeSwappedValue(&v, ShouldSwap<typename Adapter::TConfig, T>{});
}
template<size_t SIZE, typename T>
@@ -295,7 +296,7 @@ struct OutputAdapterBaseCRTP
{
static_assert(std::is_integral<T>(), "");
static_assert(sizeof(T) == SIZE, "");
writeSwappedBuffer(buf, count, ShouldSwap<typename Adapter::TConfig>{});
writeSwappedBuffer(buf, count, ShouldSwap<typename Adapter::TConfig, T>{});
}
template<typename T>
@@ -360,7 +361,7 @@ struct InputAdapterBaseCRTP
static_assert(sizeof(T) == SIZE, "");
static_cast<Adapter*>(this)->template readInternalValue<sizeof(T)>(
reinterpret_cast<typename Adapter::TValue*>(&v));
swapDataBits(v, ShouldSwap<typename Adapter::TConfig>{});
swapDataBits(v, ShouldSwap<typename Adapter::TConfig, T>{});
}
template<size_t SIZE, typename T>
@@ -370,7 +371,7 @@ struct InputAdapterBaseCRTP
static_assert(sizeof(T) == SIZE, "");
static_cast<Adapter*>(this)->readInternalBuffer(
reinterpret_cast<typename Adapter::TValue*>(buf), sizeof(T) * count);
swapDataBits(buf, count, ShouldSwap<typename Adapter::TConfig>{});
swapDataBits(buf, count, ShouldSwap<typename Adapter::TConfig, T>{});
}
template<typename T>