os.write(reinterpret_cast<char const*>(&r1), sizeof(r1));
- that's unlikely to do what you want. Whenever you need to write
reinterpret_cast
, your first thought should be "this can't be right, I'm probably doing it wrong" (and you'll usually be right). The
correct use cases for
reinterpret_cast
(and it's C-style cast brother) are
very few and
very narrow. Whenever I see a
reinterpret_cast
or C-style cast in a code review, my first thought is always "I need to read this carefully, there's
probably a bug here". —
Jesper Juhl 57 secs ago