I just watched video[0] that argues if you can consteval something, then it must be free of UB, which seems compelling, at least for these lower level helpers.
Unfortunately, it seems memcpy is not constexpr, so cannot be used like this, but std::bit_cast actually works[1] as constexpr, so I think in C++ that would now be the most preferred use. It won't allow the union either.
scoopr · · focus · HN ↗
Unfortunately, it seems memcpy is not constexpr, so cannot be used like this, but std::bit_cast actually works[1] as constexpr, so I think in C++ that would now be the most preferred use. It won't allow the union either.
[0] <a href="https://www.youtube.com/watch?v=-LAXqqqX274" rel="nofollow">https://www.youtube.com/watch?v=-LAXqqqX274 [1] <a href="https://godbolt.org/z/xGzjTMGvv" rel="nofollow">https://godbolt.org/z/xGzjTMGvv
rfgplk · · focus · HN ↗