mirror of
https://github.com/fraillt/bitsery.git
synced 2026-08-18 17:20:00 +00:00
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user