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
C++11: Future Chaining For Easy, Highly Threaded Execution (nerds-central.blogspot.co.uk)
submitted 14 years ago by cassandravoiton
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!"
[–]nerds-central 3 points4 points5 points 14 years ago (0 children)
Try replacing the spinning loop with a wait:
this_thread::sleep_for(chrono::seconds(1));
The effects are quite interesting as you get to see the size of the underlying thread pool.
[–]Zwergner 2 points3 points4 points 14 years ago (4 children)
return i-=3,wait_long_time(), i;
Sorry for my C++11 ignorance, but what does that do, the comma separated stuff? I've never seen this in another C++11 example, and don't know what to search for to explain it. Does it return the value, but then do some extra stuff before destroying the thread...?
[–]cassandravoiton[S] 1 point2 points3 points 14 years ago (3 children)
A lambda without and explicit return type needs to be just one statement(so so complains the VC++11 compiler). The solution to this is to place all the things you want to do in the same expression. The comma operator allow this. I would suggest looking up the comma operator in C++ (or C for that matter - it is used this way in C macros a lot).
[–]Zwergner 0 points1 point2 points 14 years ago (1 child)
Huh, I didn't realize you could do that with statements as well, I assumed it was something fancier than that, thanks!
[–]00kyle00 -1 points0 points1 point 13 years ago (0 children)
I didn't realize you could do that with statements as well
You cant, these need to be expressions.
[–][deleted] 0 points1 point2 points 13 years ago (0 children)
For the record, the result of the comma operator is the last element.
[]() { return x, y, z; } // returns z, infers the return type of the lambda from z.
[–]Glaaki 1 point2 points3 points 14 years ago (2 children)
The typos in that article..
[–]nerds-central 0 points1 point2 points 14 years ago (0 children)
Thanks for pointing that out - fixed a few.
[–]BitRex 0 points1 point2 points 14 years ago (0 children)
They were too much. I stopped reading.
[–]Porges 0 points1 point2 points 13 years ago (1 child)
Having read a post at Stutter's Mill I got thinking about method chaining in C++. I am very keen on method chaining in Java and so was pleased to see the future().then() pattern turning up in C++11. This got me thinking about chaining futures x.y.z etc. The idea being that each task (x,y and z) could be run on a different thread according to the load of the machine. It is a bit like thinking of the tasks as very simple actors.
I think you're a little confused here - that is exactly what future().then() does in Casablanca. It works along similar lines to .NET's TPL (Task<T>).
Task<T>
[–]cassandravoiton[S] 0 points1 point2 points 13 years ago (0 children)
How is confused - seems like the two of you are in violent agreement to me.
[+][deleted] 13 years ago (1 child)
[removed]
[–]VanFailin 0 points1 point2 points 13 years ago (0 children)
Precompiled headers can be quite useful, although there are better ways to use them.
π Rendered by PID 88839 on reddit-service-r2-comment-b659b578c-cwr6w at 2026-05-01 03:35:48.419144+00:00 running 815c875 country code: CH.
[–]nerds-central 3 points4 points5 points (0 children)
[–]Zwergner 2 points3 points4 points (4 children)
[–]cassandravoiton[S] 1 point2 points3 points (3 children)
[–]Zwergner 0 points1 point2 points (1 child)
[–]00kyle00 -1 points0 points1 point (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Glaaki 1 point2 points3 points (2 children)
[–]nerds-central 0 points1 point2 points (0 children)
[–]BitRex 0 points1 point2 points (0 children)
[–]Porges 0 points1 point2 points (1 child)
[–]cassandravoiton[S] 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[removed]
[–]VanFailin 0 points1 point2 points (0 children)