Yeah, you could use it for that, but it’s got some caveats and is unsafe in some cases.<a href="https://en.cppreference.com/cpp/language/reinterpret_cast" rel="nofollow">https://en.cppreference.com/cpp/language/reinterpret_castEDIT: If you’re able to use C++20 then clearly bit_cast is better.
reinterpret_cast<> for punning purposes can lead to UB. The recommended C++ alternative to avoid UB is bit_cast<><a href="https://stackoverflow.com/questions/53401654/why-was-stdbit-cast-added-if-reinterpret-cast-could-do-the-same" rel="nofollow">https://stackoverflow.com/questions/53401654/why-was-stdbit-...
K0IN · · focus · HN ↗
sheafification · · focus · HN ↗
<a href="https://en.cppreference.com/cpp/language/reinterpret_cast" rel="nofollow">https://en.cppreference.com/cpp/language/reinterpret_cast
EDIT: If you’re able to use C++20 then clearly bit_cast is better.
jasode · · focus · HN ↗
<a href="https://stackoverflow.com/questions/53401654/why-was-stdbit-cast-added-if-reinterpret-cast-could-do-the-same" rel="nofollow">https://stackoverflow.com/questions/53401654/why-was-stdbit-...
leni536 · · focus · HN ↗