mirror of
https://github.com/matrix-construct/construct
synced 2024-12-23 22:13:55 +01:00
ircd::util: Improve bswap template codegen.
This commit is contained in:
parent
81b6c7b003
commit
c60fc0ccdd
1 changed files with 10 additions and 3 deletions
|
@ -138,11 +138,18 @@ ircd::util::bswap(T *const val)
|
|||
noexcept
|
||||
{
|
||||
assert(val != nullptr);
|
||||
const auto ptr
|
||||
const auto &src
|
||||
{
|
||||
reinterpret_cast<uint8_t *>(val)
|
||||
reinterpret_cast<const uint8_t *>(val)
|
||||
};
|
||||
|
||||
std::reverse(ptr, ptr + sizeof(T));
|
||||
T tmp;
|
||||
const auto &dst
|
||||
{
|
||||
reinterpret_cast<uint8_t *>(&tmp)
|
||||
};
|
||||
|
||||
std::reverse_copy(src, src + sizeof(T), dst);
|
||||
*val = tmp;
|
||||
return *val;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue