C++

Type punning done right -- Mateusz Pusz

Mateusz Pusz's fourth article in a series on C++ fundamentals covers cases where reinterpret_cast is well-defined. It walks through reading an object's bytes via char, unsigned char or std::byte, aliasing through a signed/unsigned pair, converting between a struct and its first member, and round-tripping a pointer through std::uintptr_t. Reading an object representation as bytes underpins serialization, hashing and hex dumps.

AI-written summary, checked against the cited sources. How summaries work

Read at isocpp.org