21 ms·
I really wish C and C++ had an explicit type punning operator. They are systems programming languages and this is very often needed.
by TwoBit 6y ago
I really wish C and C++ had an explicit type punning operator. They are systems programming languages and this is very often needed.
- Kranar 6y agoC++20 introduces bit_cast to do this. The implementation of bit_cast is semantically equivalent to using memcpy.
- enriquto 6y agoCasting pointers in C used to work back in the day. It still works in most cases (except with aggressive optimization options), but it may may make some people uneasy.