8 ms·
Previously: https://news.ycombinator.com/item?id=17910851 https://news.ycombinator.com/item?id=17910851 https://news.ycombinator.com/item?id=12889855 https://
by saagarjha 7y ago
Previously:
https://news.ycombinator.com/item?id=17910851 https://news.ycombinator.com/item?id=17910851
https://news.ycombinator.com/item?id=12889855 https://news.ycombinator.com/item?id=12889855
Some new developments:
> C++ allows us to write the same function in much more readable way by employing some template programming. We’ll introduce a generic type called const_unaligned_pointer.
If you support C++20, there's std::bit_cast: https://en.cppreference.com/w/cpp/numeric/bit_cast https://en.cppreference.com/w/cpp/numeric/bit_cast
Edit: fixed link. Thanks, nkurz.
- deleted 7y ago[deleted]
- userbinator 7y agoI think something has gone very wrong with the state of programming when the original C version reads extremely straightforwardly, the version that works without UB already looks quite a bit more noisy, and the C++ version is just... yuck! In this case, just writing the appropriate Asm instructions themselves would've been much shorter and simpler, and also worked the first time.
- userbinator 7y ago...and something has certainly gone very wrong when you get downvoted for pointing out the truth! A lot of this idiotic complexity increase would be completely avoided if compiler authors would just exercise some common sense, but unfortunately it's not so common after all.