No. Sorry for being unclear. [1] is a great video that covers a lot of good stuff in particular this usability bug. It's worth watching in its entirety. If you don't want to sit through the video, here's the broken code in question: void Obj::update() noexcept { unique_lock (m_mutex); do_the_mutation(); } "unique_lock (m_mutex);" has no effect, but you might mistakenly think that this will block on m_mutex. Labeling…
Ahh, that makes sense! On my phone at the moment but will check out the video too, thanks!
Could someone please explain why you'd put nodiscard on a constructor? I'm a bit confused as to when that's needed.
To avoid this insidious bug: std::lock_guard (m); // guard is immediately thrown away versus the correct std::lock_guard g(m); // hold mutex til end of scope
Note for people who don’t see the difference: if a guard doesn’t have a name, it won’t survive until the end of the scope, thus doesn’t guard anything.
Whenever I see new C++ features I'm all the more impressed with how Zig manages to provide capabilities similar to -- and at least as powerful as -- type templates, value templates, constexprs, concepts, and conditional compilation (preprocessor), with a single feature and keyword, without any type/template-level programming, a preprocessor or AST macros (i.e. mini-languages different from the ordinary computation language that one has to learn and can make code quite opaque), all in a language that is about as simple as C and can be fully learned in a day or two.
Could someone please explain why you'd put nodiscard on a constructor? I'm a bit confused as to when that's needed.
After not using C++ for 15+ years , looking at it now makes my eyes bleed.
That's how I felt looking at C++17 deduction guides, and that's even though I've actually been using C++. If you haven't seen them yet you should check them out ;)
To avoid this insidious bug: std::lock_guard (m); // guard is immediately thrown away versus the correct std::lock_guard g(m); // hold mutex til end of scope
Note for people who don’t see the difference: if a guard doesn’t have a name, it won’t survive until the end of the scope, thus doesn’t guard anything.
Whenever I see new C++ features I'm all the more impressed with how Zig manages to provide capabilities similar to -- and at least as powerful as -- type templates, value templates, constexprs, concepts, and conditional compilation (preprocessor), with a single feature and keyword, without any type/template-level programming, a preprocessor or AST macros (i.e. mini-languages different from the ordinary computation la…
Whenever I see new C++ features I'm all the more impressed with how Zig manages to provide capabilities similar to -- and at least as powerful as -- type templates, value templates, constexprs, concepts, and conditional compilation (preprocessor), with a single feature and keyword, without any type/template-level programming, a preprocessor or AST macros (i.e. mini-languages different from the ordinary computation la…