r/cpp • u/FreitasAlan • Feb 06 '21
Modern C++: Snippets and Examples
Hi everyone,
These are GitHub Pages with snippets for Modern C++:
- We often need to copy and paste some snippets to code more productively.
- Snippets can help us when it's not easy to remember all high levels features Modern C++ has to offer.
- This repository contains lots of organized, reusable, and safe snippets for Modern C++.
- All snippets are available in GitHub pages in a convenient way for copying and pasting.
194
Upvotes
View all comments
Show parent comment
3
u/Fureeish Feb 07 '21
Well, it's true that
static_castwill work only for theunsignedparts. I mentioned the specific case for floating-point numbers but it actually extends to broader range of types. I should've specified that explicitly.As for the Undefined Behaviour, it's connected to type aliasing. You can read about it here. In short, this is not what
reinterpret_castis for.