Skip to main content

All Questions

Tagged with
10 votes
2 answers
280 views

Does nullptr_t break type punning or pointer conversions?

Consider this union: typedef union { void* vptr; nullptr_t nptr; } pun_intended; nullptr_t is supposedly compatible with void* 1). Ok so what if we initialize the void* to some non-zero ...
Lundin's user avatar
  • 208k
2 votes
1 answer
350 views

Implementing std::bit_cast equivalent in C

Is it possible to implement something similar to C++20's std::bit_cast in C? It would be a lot more convenient than using union or casting pointers to different types and dereferencing. If you had a ...
Jan Schultke's user avatar
  • 36.1k