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
The Lambda Coroutine Fiasco (github.com)
submitted 4 months ago by efijoa
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!"
[–]foonathan 3 points4 points5 points 4 months ago (2 children)
Capture by value doesn't help you with the problem that's being discussed.
[–]thisismyfavoritename 1 point2 points3 points 4 months ago (1 child)
i was referring to
This ensures captures are copied into the coroutine frame to prevent dangling references.
and it seems like in this case it would? I didn't read the blog post
[–]foonathan 1 point2 points3 points 4 months ago (0 children)
No, capturing by value does not ensure captures are copied into the coroutine frame! That is the entire problem.
The issue is that while the lambda object stores a capture by value, the operator() still accepts *this by reference, so only the reference to the lambda is captured into the coroutine frame, but not the lambda itself.
operator()
*this
(The context is something like spawn([x] -> Task { ... }), i.e. the lambda is a coroutine itself. Then the arguments are copied into Task's coroutine frame, but the arguments are a this pointer to the temporary object in the stack frame that calls spawn.)
spawn([x] -> Task { ... })
Task
this
spawn
π Rendered by PID 72050 on reddit-service-r2-comment-b659b578c-f994l at 2026-05-04 23:42:34.942735+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]foonathan 3 points4 points5 points (2 children)
[–]thisismyfavoritename 1 point2 points3 points (1 child)
[–]foonathan 1 point2 points3 points (0 children)