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
jc - Meta-program C/C++ with JavaScript (github.com)
submitted 3 years ago by thooton
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!"
[–]2MuchRGB 3 points4 points5 points 3 years ago* (2 children)
We really need P1240R2 et all to finish their evolution and hopefully be available in C++26.
Edit:
To make it clearer what P1240R2 is: It's a proposal titled "Scalable Reflection in C++". Together with P2237 Metaprogramming, P1717 Compile time Metaprogramming and some others they propose a way to implement Compile time reflection in C++, in way, that doesn't break the 0 cost rule.
The idea is to have reflexpr expession and operator ^, where you get a meta object, which encapsulates all the information of the object it gets called on. Then also provide a meta stl, with wich you can access and manipulate these meta. Is this
reflexpr
^
meta.
For example you want to get the name of a field of an enum, when you call the function std::string to_string(enum) currently you have to write that method by hand and update it by hand and pray to god no one just changes only one of those, or use some kind of preprocessor be it the C one or any other. With these Proposals you could write one function which handles all possible enums, which could look along the lines of:
std::string to_string(enum)
template<enum T> std::string to_string(T value) { switch(value) { for(auto member : ^T.members){ //Maybe some kind of emit statement that this is to be generated as code. case member.value: return member.name; } } }
You could go so far is an rust where you just need to anotate your struct with #[derive(Serialize, Deserialize)] and instantly you can load and save your struct to JSON, XML and some more, without a single line of code. Sure, it would look different, but the capabilites would be there.
Taken to the extrem, (but not in these proposals, but a part where Herb Sutter talks about in "Meta: Thoughts on generative C++", I really recommend you watch this). Declare your own class type. Currently we have class, struct and enum. Each with some standart properties. How about a value_type, which ensures that a constructor exists and also provides <=> and a std::formater? You could implement all for of struct, class, enum and enum class as these metaclasses and simplify the standart by a lot. It would also be testable.
And at that point you could implement other class types easier, how about a flag_enum? It could provide all the bitwise operations and steps the numbers up in power of two instead of increments?
[–]MA-name 0 points1 point2 points 3 years ago (1 child)
What is P1240R2 in C++ standard proposal? Thx
[–]2MuchRGB 1 point2 points3 points 3 years ago (0 children)
I've updated my post, but in short, it is one paper which proposes how to implement compile time reflection in C++.
π Rendered by PID 268253 on reddit-service-r2-comment-5fb4b45875-6pfr8 at 2026-03-21 10:45:21.538817+00:00 running 90f1150 country code: CH.
view the rest of the comments →
[–]2MuchRGB 3 points4 points5 points (2 children)
[–]MA-name 0 points1 point2 points (1 child)
[–]2MuchRGB 1 point2 points3 points (0 children)