Type punning via unions in C++ invokes undefined behavior. Instead, leverage BitCast, our variant of C++2a's std::bit_cast