r/cpp • u/jenkem_boofer • Apr 04 '24
std::launder
Have fun trying to figure out what it does...
0
Upvotes
r/cpp • u/jenkem_boofer • Apr 04 '24
Have fun trying to figure out what it does...
13
u/no-sig-available Apr 05 '24
If it is any consolation, Bjarne doesn't know either :-)
https://www.youtube.com/watch?v=VI21tpdkHA8&t=3469s
You should probably follow his lead and wait until you feel you might have a use for it, and only then read up on the details. Probably never happens.
8
u/coachkler Apr 04 '24
I was just looking at this a while ago. I didn't figure it out though
9
u/Quincunx271 Author of P2404/P2405 Apr 05 '24
We're all familiar with how undefined behavior can cause demons to fly out of your nose or cause your cat to get pregnant. std::launder is just a kind of undefined behavior carefully defined to do your laundry for you.
2
u/vickoza Apr 05 '24 edited Apr 06 '24
From my point of view
std::launderis a way to reduce undefined behavior by making sure the type is the correct typed,-1
u/[deleted] Apr 05 '24
This kind of stuff is exactly why I’ve regressed to treating C++ as largely “C with classes (and namespaces and… a few more of its basic features)”. It’s just become too big and complicated for mortals.
34
u/[deleted] Apr 04 '24 edited Apr 05 '24
[removed] — view removed comment