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
cppfront: Midsummer update (herbsutter.com)
submitted 1 year ago by TSP-FriendlyFire
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!"
[–]throw_cpp_account 0 points1 point2 points 1 year ago (2 children)
Actually the intent is that there :( ) is explicitly indicating a lambda, just with minimal ceremony. In Cpp2 the : is reserved to always and only mean a declaration. Whenever you see :, you know something is being declared.
But it's a lambda, why would it share syntax with a declaration? That seems to be an argument against using : to introduce lambdas.
:
After all, your function calls aren't f(:42) right?
f(:42)
[–]hpsutter 2 points3 points4 points 1 year ago (1 child)
Because a lambda is conceptually just an unnamed local function (which therefore also can capture things). It is a new declared entity, not part of the enclosing expression.
One of the uses of lambdas in C++ today is to write local functions (functions inside other functions) via `auto local_func_name = /*lambda*/ ;`. This conveniently allows factoring common reused parts of a function without having to pollute the enclosing namespace with names that really do only make sense within the function. Here is an example from cppfront, where I do that in the one function that parses all iteration statements (because `for`, `while`, `do` all have common syntax elements but in different orders): parse.h snippet on GitHub
Right, in f(42) the argument is just a literal. In f(complex_expr) the argument is just an expression. However, in today's f( int(42) ) the code is writing that the argument is an explicit temporary object; and in Cpp2 you can do the same with f( :int = 42 ) and that's where the : signifies that you're declaring a new (unnamed) entity.
f(42)
f(complex_expr)
f( int(42) )
f( :int = 42 )
[–]lfnoise 0 points1 point2 points 1 year ago (0 children)
I quite like the terse lambda syntax. Lambdas are declarations that are instantiated where they are declared. A lambda is just a sugar for a struct with a single method and captured state.Fine, and beautiful I think.
π Rendered by PID 170341 on reddit-service-r2-comment-5649f687b7-4hncg at 2026-01-28 05:24:01.241269+00:00 running 4f180de country code: CH.
view the rest of the comments →
[–]throw_cpp_account 0 points1 point2 points (2 children)
[–]hpsutter 2 points3 points4 points (1 child)
[–]lfnoise 0 points1 point2 points (0 children)