MCPcopy Create free account
hub / github.com/fmtlib/fmt / bit_cast

Function bit_cast

include/fmt/format.h:268–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

266// Implementation of std::bit_cast for pre-C++20.
267template <typename To, typename From, FMT_ENABLE_IF(sizeof(To) == sizeof(From))>
268FMT_CONSTEXPR20 auto bit_cast(const From& from) -> To {
269#ifdef __cpp_lib_bit_cast
270 if (is_constant_evaluated()) return std::bit_cast<To>(from);
271#endif
272 auto to = To();
273 // The cast suppresses a bogus -Wclass-memaccess on GCC.
274 memcpy(static_cast<void*>(&to), &from, sizeof(to));
275 return to;
276}
277
278inline auto is_big_endian() -> bool {
279#ifdef _WIN32

Callers

nothing calls this directly

Calls 2

is_constant_evaluatedFunction · 0.85
is_big_endianFunction · 0.85

Tested by

no test coverage detected