carb::cpp20::bit_cast

Defined in carb/cpp20/Bit.h

template<class To, class From, std::enable_if_t<details::SizeMatches<To, From>::value && std::is_trivially_copyable<From>::value && std::is_trivially_copyable<To>::value, bool> = false>
To carb::cpp20::bit_cast(const From &src)

Re-interpets the bits src as type To.

See: https://en.cppreference.com/w/cpp/numeric/bit_cast

Note

The To and From types must exactly match size and both be trivially copyable.

Template Parameters
  • To – The object type to convert to.

  • From – The (typically inferred) object type to convert from.

Parameters

src – The source object to reinterpret.

Returns

The reinterpreted object.