5 ms·
I've been out of C++ for a couple of years now, but std::call_once is totally new to me, despite being in C++11. It really is a language where if you got 5 dif
by physicsguy 3y ago
I've been out of C++ for a couple of years now, but std::call_once is totally new to me, despite being in C++11.
It really is a language where if you got 5 different people to write a solution to something you'd get 5 wildly different answers.
- tialaramex 3y agoSix, at least. Also at least one of the answers the five people swear they use will turn out to be either Undefined Behaviour or a quirk of one particular compiler/ toolchain. Like sure, volatile integers are basically just atomic variables with easier syntax... if you are on x86-64 and using MSVC. Otherwise no they really aren't.
- mihaaly 3y agoA nice, related meme: https://mikelui.io/img/c++_init_forest.gif https://mikelui.io/img/c++_init_forest.gif
- tialaramex 3y agoAnd on that subject https://leanpub.com/cppinitbook https://leanpub.com/cppinitbook - a book just about initialization in C++ which is in some sense (more pages) longer than my edition of K&R ("The C Programming Language"). Despite all this complexity, C++ 23 has problems with mistakenly uninitialized variables and still lacks a coherent strategy to do deferred initialization correctly.
- classified 3y agoThat GIF should mention the relevant C++ standard, because next year there will be at least one more additional way to initialize.
- moralestapia 3y agoI consider that a feature tho.
- tiagod 3y agoAfter working on golang projects for a while, I really like having one obvious way to do things.