Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
TwoBit
· 6y ago · 0 comments
I really wish C and C++ had an explicit type punning operator. They are systems programming languages and this is very often needed.
Comments
[–]
Kranar
6y ago
C++20 introduces bit_cast to do this. The implementation of bit_cast is semantically equivalent to using memcpy.
[–]
enriquto
6y ago
Casting 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.