[ox/std] Add cbit_cast as a stop-gap until I can implment a normal constexpr bit_cast

This commit is contained in:
Gary Talent 2021-04-24 15:43:11 -05:00
parent 24f26d822a
commit 75902ba2a3

View File

@ -14,6 +14,13 @@
namespace ox { namespace ox {
template<typename To, typename From>
constexpr typename enable_if<sizeof(To) == sizeof(From), To>::type cbit_cast(From src) noexcept {
To dst;
ox_memcpy(&dst, &src, sizeof(src));
return dst;
}
template<typename To, typename From> template<typename To, typename From>
typename enable_if<sizeof(To) == sizeof(From), To>::type bit_cast(From src) noexcept { typename enable_if<sizeof(To) == sizeof(From), To>::type bit_cast(From src) noexcept {
To dst; To dst;