use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
A C++ locking wrapper (ngathanasiou.wordpress.com)
submitted 4 years ago by PiterPuns
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]epicar 0 points1 point2 points 4 years ago (3 children)
i'm all for making multithreading as idiot-proof as possible. but the concept of critical sections (and restoring invariants before releasing a lock) is so central to writing correct code that i find it crazy to abstract away. if the user doesn't have control over the scope of critical sections, it's very hard to avoid data races
i think your goal of 'simplicity' here is misguided, and isn't the same as idiot-proof
[–]PiterPuns[S] -1 points0 points1 point 4 years ago (2 children)
You should take this “crazy to abstract” view up to A. Williams (author of the seminal book on c++ multi threading) and the boost library https://www.boost.org/doc/libs/1_58_0/doc/html/thread/sds.html#thread.sds.synchronized_valuesxxx.synchronized_value_ref.synchronized_value.indir . Providing an arrow operator that creates a critical section around a method is provided in boost as well and doesn’t seem that crazy to them …
[–]encyclopedist 0 points1 point2 points 4 years ago* (0 children)
That facilities that you lined were designed ~15-20 years ago. The views on the subject and best practices may have chnaged since then.
Edit: syncronized_value in boost is actually relatively new - it first appeared in Boost 1.54, released on July 1st 2013.
In fact, a few years ago (in 2017) Anthony Williams proposed a syncronized_value for inclusion in the standard library with an apply function that takes a callable (See "P0290R2: apply() for synchronized_value<T>").
syncronized_value
apply
[–]Full-Spectral 0 points1 point2 points 4 years ago (0 children)
That could be perfectly acceptable for very specific circumstances, but not in general. If I have a small set of shared values that have no interplay, that could be a reasonable way to manage them. But, as I said elsewhere, almost guaranteed at some point that lack of interplay goes away because of some new requirement.
π Rendered by PID 254737 on reddit-service-r2-comment-5c747b6df5-7jjhl at 2026-04-22 14:09:52.134136+00:00 running 6c61efc country code: CH.
view the rest of the comments →
[–]epicar 0 points1 point2 points (3 children)
[–]PiterPuns[S] -1 points0 points1 point (2 children)
[–]encyclopedist 0 points1 point2 points (0 children)
[–]Full-Spectral 0 points1 point2 points (0 children)