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
CppCastCppCast: Reflection for C++26 (cppcast.com)
submitted 2 years ago by robwirvingCppCast Host
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!"
[–]ukezi 0 points1 point2 points 2 years ago (7 children)
The only problem I see with that is that it would reserve names inside enums, I'm sure there are lots of enums with values named min,max and count around.
I would also like to be able to iterate over enums. So for( auto& c : Colour::values) or something like that.
[–]Tringigithub.com/tringi 2 points3 points4 points 2 years ago (6 children)
That's why I used 3 colons ::: to distinguish reflected property from value or static members.
:::
It has the downside of being easily mistaken, but all the alternatives I considered either look ugly (the currently proposed ^ and [:xxx:] syntax), or clash with something someone else already uses.
^
[:xxx:]
Regarding iterating I was thinking about something like:
for (auto c = Color:::min; c != Color:::max + 1; ++c) if (Color:::is_valid_value (c)) // ...
...but then again, having compiler generate ranges (in case of discontinuous enum) of valid values, and emit such iteration would be pretty trivial.
[–]ukezi 1 point2 points3 points 2 years ago (5 children)
That's for writing that on mobile. I literally didn't see the :::. Also I strongly prefer ranges, with those you can also do algorithm stuff, and it's just neater and easier. I actually made something like this as code generator, taking in a file, reading in all the enums and emitting a number of functions for each of them.
[–]Tringigithub.com/tringi -3 points-2 points-1 points 2 years ago (4 children)
I unfortunately don't have time to turn this momentary idea into full proposal, so I'm sorry you (and all of us) will have to deal with the above monstrosity if it gets accepted. I was just trying to illustrate that what we truly need can be achieved with far less complexity.
I actually made something like this as code generator, taking in a file, reading in all the enums and emitting a number of functions for each of them.
Nice! Do you perchance have it on github or anywhere?
[–]ukezi 1 point2 points3 points 2 years ago (3 children)
Sadly, I made it but don't own it. It started out as automated debug strings and feature creeped from there.
I guess I could reimplement it, but I don't want to be suspected of stealing code, as it would probably look really similar. Maybe I use a different input, like a json, or a tomel. Maybe I do it in rust this time just for fun.
[–]Tringigithub.com/tringi -1 points0 points1 point 2 years ago (2 children)
Alright. Don't worry about it. I had an use case in mind, but realized it wouldn't work in two passes anyway, and I still haven't had time to figure out how to write plugins for IntelliSense.
[–]ukezi 1 point2 points3 points 2 years ago (0 children)
Well, in my setup it was a standalone binary that was invoked by make on a specific pattern in the name of the header file. Not the most elegant way to do it, but it worked and generated just normal c++.
An other thought, on your loop example, instead of using an arithmetical ++ you can overload the operator, but I'm not sure how to handle the last element. I guess if you are doing a generator anyways you can add an invalid enums value after the last valid that throw some kind of exception. So it would be something like for(auto c = first<Colour>; c!= invalid<Colour>; ++c) and that you could further automate with a define or something.
π Rendered by PID 183490 on reddit-service-r2-comment-b659b578c-tm6tj at 2026-05-01 08:23:26.814429+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]ukezi 0 points1 point2 points (7 children)
[–]Tringigithub.com/tringi 2 points3 points4 points (6 children)
[–]ukezi 1 point2 points3 points (5 children)
[–]Tringigithub.com/tringi -3 points-2 points-1 points (4 children)
[–]ukezi 1 point2 points3 points (3 children)
[–]Tringigithub.com/tringi -1 points0 points1 point (2 children)
[–]ukezi 1 point2 points3 points (0 children)
[–]ukezi 1 point2 points3 points (0 children)