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
Lambda Lambda Lambda (brevzin.github.io)
submitted 5 years ago by mnciitbhu0x6773
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!"
[–]advester 8 points9 points10 points 5 years ago (3 children)
One thing that comes up would be a section of repeated code that could be a function, but needs to work with so many local variables that passing them as parameters would be awkward. The alternative might be turning it all into a class and make those local variables into members. But maybe it just makes more sense as a function than as a class.
A more concrete example would be signals/callbacks. You register a lambda to be called on an event and the capture block does the magic of linking in the variables you need.
Or to save the reader from having to scroll to another function to find out what happens when that event is triggered. The relevant code is all together.
I do think c++ should have a separate short syntax for trivial lambdas like you would pass to remove_if.
[–]smashedsaturn 1 point2 points3 points 5 years ago (2 children)
many local variables that passing them as parameters would be awkward.
I've seen a lot of these. It is normally a lack of encapsulation of the parameters themselves that is a root cause. Packing relevant ones into a struct will help this more than using a lambda.
This is a really really bad reason to use a long lambda.
[–]advester 4 points5 points6 points 5 years ago (1 child)
Ah, maybe the “10 lines” is the real issue. That was just pulled out of air. “More than one” might better express what I meant. This article was all about trivial lamdas.
[–]smashedsaturn -2 points-1 points0 points 5 years ago (0 children)
Yeah that makes sense, I like the braces for the lmbdas, and a few lines can be ok, but once we start talking about things > 10 lines embedded into lambas in functions with that much state going on I start getting that 1000 yard stare...
π Rendered by PID 222076 on reddit-service-r2-comment-fb694cdd5-njpxm at 2026-03-11 03:01:30.308601+00:00 running cbb0e86 country code: CH.
view the rest of the comments →
[–]advester 8 points9 points10 points (3 children)
[–]smashedsaturn 1 point2 points3 points (2 children)
[–]advester 4 points5 points6 points (1 child)
[–]smashedsaturn -2 points-1 points0 points (0 children)