diff options
Diffstat (limited to 'common/albit.h')
-rw-r--r-- | common/albit.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/common/albit.h b/common/albit.h index 82a4a00d..d54a189c 100644 --- a/common/albit.h +++ b/common/albit.h @@ -1,6 +1,7 @@ #ifndef AL_BIT_H #define AL_BIT_H +#include <array> #include <cstdint> #include <cstring> #include <limits> @@ -17,9 +18,9 @@ std::enable_if_t<sizeof(To) == sizeof(From) && std::is_trivially_copyable_v<From && std::is_trivially_copyable_v<To>, To> bit_cast(const From &src) noexcept { - alignas(To) char dst[sizeof(To)]; - std::memcpy(&dst[0], &src, sizeof(To)); - return *std::launder(reinterpret_cast<To*>(&dst[0])); + alignas(To) std::array<char,sizeof(To)> dst; + std::memcpy(dst.data(), &src, sizeof(To)); + return *std::launder(reinterpret_cast<To*>(dst.data())); } #ifdef __BYTE_ORDER__ |