We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bcf361a commit d49ec10Copy full SHA for d49ec10
include/skyr/v2/platform/endianness.hpp
@@ -15,9 +15,10 @@ namespace details {
15
template <class intT>
16
requires std::is_integral_v<intT> constexpr inline auto swap_endianness(intT v) noexcept -> intT {
17
constexpr auto byte_count = sizeof(v);
18
- std::array<unsigned char, byte_count> bytes{};
19
- for (auto i = 0UL; i < byte_count; ++i) {
20
- bytes[i] = static_cast<unsigned char>(v >> (i * 8));
+ constexpr auto bit_count = 8ul;
+ std::array<std::byte, byte_count> bytes{};
+ for (auto i = 0ul; i < byte_count; ++i) {
21
+ bytes[i] = static_cast<std::byte>(v >> (i * bit_count));
22
}
23
return *static_cast<const intT *>(static_cast<const void *>(bytes.data()));
24
0 commit comments