15 #include <type_traits> 66 template <
class Dest,
class Source>
70 sizeof(Dest) ==
sizeof(Source),
71 "bit_cast requires source and destination to be the same size");
73 std::is_trivially_copyable<Dest>::value,
74 "bit_cast requires the destination type to be copyable");
76 std::is_trivially_copyable<Source>::value,
77 "bit_cast requires the source type to be copyable");
79 memcpy(&dest, &source,
sizeof(dest));
Dest bit_cast(const Source &source)
void memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) noexcept
An OS and compiler independent version of "memcpy".