42 if constexpr (
sizeof(T) == 1u) {
45 static_assert(std::has_unique_object_representations_v<T>,
46 "T may not have padding bits");
47 auto value_representation = std::bit_cast<std::array<std::byte,
sizeof(T)>>(value);
48 std::ranges::reverse(value_representation);
49 return std::bit_cast<T>(value_representation);
constexpr T byteswap(T value) noexcept
Perform an in-place byte swap on an integral type (if size of the type is greater than one).
Definition byteswap.hpp:41