12namespace di::vocab::detail {
13template<concepts::TriviallyRelocatable To, concepts::TriviallyRelocatable From>
14requires(
sizeof(To) ==
sizeof(From) && concepts::Trivial<From>)
15constexpr auto erasure_cast(From
const& from) -> To {
16 return bit_cast<To>(from);
19template<concepts::TriviallyRelocatable To, concepts::TriviallyRelocatable From>
20requires(
sizeof(To) ==
sizeof(From) && concepts::RValueReference<From &&>)
21constexpr auto erasure_cast(From&& from) -> To {
22 if constexpr (
requires { bit_cast<To>(from); }) {
23 return bit_cast<To>(from);
27 di::copy((
byte const*) di::addressof(from), (
byte const*) di::addressof(from) +
sizeof(From), bytes);
29 return di::bit_cast<To>(bytes);
std::byte byte
Definition byte.h:64
constexpr auto unsafe_forget
Steal ownership of an object and do not its destructor.
Definition unsafe_forget.h:32
constexpr auto copy
Definition copy.h:30