4 ms·
Using obscure works makes some people feel smart.
by HyperSane 3y ago
Using obscure works makes some people feel smart.
- malkia 3y agoExplain std::launder then - https://en.cppreference.com/w/cpp/utility/launder https://en.cppreference.com/w/cpp/utility/launder - it's simple word, mostly used when talking about dirty money ;) - but hey - I've still no idea how/when/why to use it... ;)
- saghm 3y agoUsing simple words in confusing contexts also makes people feel smart. Essentially any way of being technically correct in confusing ways has this effect; "I'm so much smarter that you can't even understand _why_ I'm right" is too juicy a flex for some people to avoid.
- malkia 3y agohttps://twitter.com/ciura_victor/status/1662536472342192128 https://twitter.com/ciura_victor/status/1662536472342192128 "Rinse and repeat That’s my std::launder joke " best answer I've got so far :)
- still_grokking 3y agoActually the word "launder" seems to be quite to the point given what this does. I'm not a C/C++ developer and I have to admit: For me reading anything about those languages is every time just mind-bending! (And I have a hard time not to use any curse words right now in addition). It took me over 20 minutes to understand (more or less) what this `std::launder()` does. The spec is just gibberish! So I've tried a BS generator a.k.a "AI" than[1]. Together with a Stackoverflow entry[2] it finally made click. This function "launders" pointers from compiler assumptions. It will give you a "clean", pristine pointer back, without for example the information about the concrete object attached to it previously (because for example casting an object to its base class won't give you a proper pointer to the base class; at least that's what as SO comments says… Sounds quite ill, but so is C++). It will also for example "launder" away compiler assumptions about the `const` property of an object pointer. It's needed for example when you do "in-place replacement of an object" (replacing directly the bytes in some memory area of another object). Just casting won't make the compiler "forget" where this memory came from / to which object it was once attached. So you need to launder the pointer to the new object so the compiler forgets what it assumed previously about that memory area. But let's not talk about what it actually means when a language needs some mechanism like that… My "WTF per Minute" output just reached a new all time high, I guess. [1] https://www.phind.com/search?cache=91e3f5ce-dde2-422e-a3eb-689169479882 https://www.phind.com/search?cache=91e3f5ce-dde2-422e-a3eb-6... [2] https://stackoverflow.com/questions/66176720/why-introduce-stdlaunder-rather-than-have-the-compiler-take-care-of-it https://stackoverflow.com/questions/66176720/why-introduce-s...
- malkia 3y agoHoly - the explanation you provided clicked for me! Thank you! And I should use now `phind.com` - awesome!