![]() |
Arene Base
Fundamental Utilities For Safety Critical C++
|
The bit subpackage provides backports of the C++20 <bit> header, along with other useful bit manipulation utilities.
The public header is
The Bazel target is
bit_castarene::base::bit_cast<To>(from) returns a value of type To whose object representation is bit-identical to that of from.
The specification mirrors std::bit_cast, and the call participates in overload resolution only when:
sizeof(To) == sizeof(From)std::is_trivially_copyable<To>::value is truestd::is_trivially_copyable<From>::value is trueconstexpr Availabilitybit_cast is usable in a constant expression only when the compiler provides __builtin_bit_cast (Clang 9+, GCC 11+). On toolchains without it (e.g. GCC 8), the implementation falls back to std::memcpy and therefore cannot appear in a constexpr context. Query this at compile time via the ARENE_HAS_CONSTEXPR_BIT_CAST platform support macro: