From f68181bcc3495266bb77a68df71c333b2c9293c7 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 24 Apr 2021 15:43:11 -0500 Subject: [PATCH] [ox/std] Add cbit_cast as a stop-gap until I can implment a normal constexpr bit_cast (synced from 75902ba2a30adc0607278dc6725d9b101480a354) --- src/ox/std/bit.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ox/std/bit.hpp b/src/ox/std/bit.hpp index d7d5b1c55..fd6b61b65 100644 --- a/src/ox/std/bit.hpp +++ b/src/ox/std/bit.hpp @@ -14,6 +14,13 @@ namespace ox { +template +constexpr typename enable_if::type cbit_cast(From src) noexcept { + To dst; + ox_memcpy(&dst, &src, sizeof(src)); + return dst; +} + template typename enable_if::type bit_cast(From src) noexcept { To dst;