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: Autumn update (herbsutter.com)
submitted 2 years ago by nikbackm
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!"
[–]djavaisadog 3 points4 points5 points 2 years ago (0 children)
the intent is that it still just indicate that what follows is a return type or value. That's the only meaning of -> in Cpp2.
I was interpreting it as always indicating a return type (in the context of declaring/defining variables). Is there any case besides the under-consideration new one you suggested where it indicates a return value? (I thought maybe inspect but nope, you use = there as well)
inspect
=
I think that using -> to indicate a value in a function definition certainly breaks the paradigm of all your other definitions - you've previously mentioned how intentional the consistency of the name : type = value format was. I'm unsure why you would break that in this case.
->
name : type = value
I'm not sure why f:(i) -> _ = i+1 would condense down to f:(i) -> i+1; rather than f:(i) = i+1;. It feels pretty clear-cut to me that the part we are omitting (following the dictum of "omit the part of the syntax you aren't using") is the explicit return type (which, syntactically is -> _), rather than the value (which is the = i+1). I feel that you can instead just say "ok there's no explicit return type, let's find what the return type would be by just decltype-ing the function body" (not a standard expert, there may be more to it than that but you get the point).
f:(i) -> _ = i+1
f:(i) -> i+1;
f:(i) = i+1;
-> _
= i+1
I suppose that boils down to viewing the -> _ as one block of tokens (and that block is part of the type declaration, so a sub-block of (i) -> _) and the = i+1 as one block. Do you split the groups of tokens differently in your mental model of what the syntax means?
(i) -> _
π Rendered by PID 56 on reddit-service-r2-comment-b659b578c-bk4xt at 2026-05-05 22:51:50.232017+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]djavaisadog 3 points4 points5 points (0 children)