[ox/std] Add cbit_cast as a stop-gap until I can implment a normal constexpr bit_cast
This commit is contained in:
parent
24f26d822a
commit
75902ba2a3
7
deps/ox/src/ox/std/bit.hpp
vendored
7
deps/ox/src/ox/std/bit.hpp
vendored
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user