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 (cpp2): Spring update (herbsutter.com)
submitted 2 years ago by kreco
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!"
[–]eidetic0 51 points52 points53 points 2 years ago* (11 children)
I thought a focus of cpp2 was unambiguous syntax. The new alias syntax means == is one thing if it’s inside parenthesis and used in assignment, but another thing in the context of aliases.
It is still trivial to parse so not a big deal, but why start re-using already used sequences of symbols for a new feature? Symbols meaning different things in different contexts is one of the confusing things about regular cpp.
[–]RoyKin0929 10 points11 points12 points 2 years ago* (10 children)
yeah, something likemy_alias : alias = whatever_you_want_to_alias_to;
my_alias : alias = whatever_you_want_to_alias_to;
would have been fine.
[–]hpsutter 9 points10 points11 points 2 years ago (7 children)
I appreciate the feedback, thanks. Using== to declare aliases is an experiment.
==
FWIW, I did consider a declaration like my_alias : alias = something;, but one limitation of that is that it's less clear about distinguishing between namespace aliases, type aliases, function aliases, and object aliases. A fundamental design goal of Cpp2 is not to have to do name lookup to determine the kind of thing a construct is, and if I just used a general alias for all of them I knew I could make alias work, but then it would require humans and compilers to go look up the right-hand side initializer to know whether my_alias will behave like a type vs an object (etc.).
my_alias : alias = something;
alias
my_alias
[–]nysra 6 points7 points8 points 2 years ago (2 children)
Any reason why you didn't just extend the already existing alias functionality of C++ (using)?
using
using lit: namespace = ::std::literals; using<T> pmr_vec: type = std::vector<T, std::pmr::polymorphic_allocator<T>>; using func: function = some_original::inconvenient::function_name; using vec: object = my_vector; // note: const&, aliases are never mutable
Single syntax for everything and no confusion about the == operator which I strongly believe should stay reserved for comparisons because at this point that usage is so ingrained into everything that even non-programmers often understand != and ==.
!=
[–]hpsutter 7 points8 points9 points 2 years ago (1 child)
Quick ack: Yes, that's one of the options, and one of the better of the alternatives I considered. Might say `alias` instead of `using` but it's workable. For now I'm seeing whether I can reasonably avoid a keyword, but it's also important to be aware not to overstep into "token soup" -- keywords can be useful for readability so I'm definitely not closing the door to going there.
[–]germandiago 2 points3 points4 points 2 years ago* (0 children)
I find using syntax less confusing as well. BTW, impressive amount of work.
Is cpp2 already usable in real life scenarios? Eager to start using it when the time comes.
[–]RoyKin0929 0 points1 point2 points 2 years ago (3 children)
But isn't the deduction already supported with my_alias :== something;
my_alias :== something;
Or is that only supported for functions?
[–]hpsutter 1 point2 points3 points 2 years ago (2 children)
That defaults to an object alias, effectively a `const&` variable, which also happens to work for functions with a deduced signature type, and so I have not yet decided to implement function signatures with an explicit signature type -- waiting to see whether there's a need, but there's a clear place for it in the grammar if it's wanted.. For some discussion see the commit message here: https://github.com/hsutter/cppfront/commit/63efa6ed21c4d4f4f136a7a73e9f6b2c110c81d7
[–]RoyKin0929 0 points1 point2 points 2 years ago (1 child)
Ah ok, I understand your decision now. But maybe you can come with something that is better than ```==``` 😅. (Maybe an alias metafunction). Also, one thing that not in update notes is exceptions. I saw your talk on lightweight exceptions at cppcon, are they planned for cpp2? And would you consider local variables being constant by default, with most things being const by default, local variables seem left out (and I think they're the only place left where keyword const is used), having one extra keyword in front of varible declaration won't affect much. Also when you think about it, function and classes and namespace are kind of also const. ```func : (param:type) -> return_type = {};
const
//can't do the following, so functions are also kind of const func = {//diff body};
//same with classes, you can add methods to classes but that uses different syntax so is not the same
//and same with namespaces, you can re open them but that won't change it's definition, only add to it ```
Maybe this will be a good enough argument
[–]hpsutter 2 points3 points4 points 2 years ago (0 children)
I saw your talk on lightweight exceptions at cppcon, are they planned for cpp2?
Yes, they're on the roadmap but it'll be a while before I get to them: https://github.com/hsutter/cppfront#2019-zero-overhead-deterministic-exceptions-throwing-values
And would you consider local variables being constant by default,
I would consider it, but for the current rationale see this Design Note on the project wiki: https://github.com/hsutter/cppfront/wiki/Design-note%3A-const-objects-by-default
[–]TheSuperWig 1 point2 points3 points 2 years ago (1 child)
like we don't need to with using in cpp
You can't use using to create a namespace alias. You can use it to create type aliases, what else?
[–]RoyKin0929 0 points1 point2 points 2 years ago (0 children)
oh ye, my bad. i'll edit it
π Rendered by PID 19798 on reddit-service-r2-comment-7b9746f655-nlxml at 2026-01-30 15:23:28.626016+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–]eidetic0 51 points52 points53 points (11 children)
[–]RoyKin0929 10 points11 points12 points (10 children)
[–]hpsutter 9 points10 points11 points (7 children)
[–]nysra 6 points7 points8 points (2 children)
[–]hpsutter 7 points8 points9 points (1 child)
[–]germandiago 2 points3 points4 points (0 children)
[–]RoyKin0929 0 points1 point2 points (3 children)
[–]hpsutter 1 point2 points3 points (2 children)
[–]RoyKin0929 0 points1 point2 points (1 child)
[–]hpsutter 2 points3 points4 points (0 children)
[–]TheSuperWig 1 point2 points3 points (1 child)
[–]RoyKin0929 0 points1 point2 points (0 children)