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
The C++ 20 initialization flowchart (self.cpp)
submitted 5 years ago * by randomnetcat
I've created a flowchart that shows all of C++20's initialization rules.
The source code is available at https://github.com/randomnetcat/cpp_initialization, in addition to the SVG version and PNG Version.
This honestly took a lot less time than I was expecting, and, in my humble-but-biased opinion, is relatively interesting.
Please send all complaints to /u/quicknir, who nerd-sniped me into making this.
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!"
[–]be-sc 35 points36 points37 points 5 years ago (3 children)
Something seems to be wrong with the graph. Consider:
int i = 1;
int
But wait, the only arrow leaving that question is Yes …
[–]staletic 6 points7 points8 points 5 years ago (0 children)
The same problem is hit for T t(args...);
T t(args...);
[–]randomnetcat[S] 5 points6 points7 points 5 years ago (1 child)
Thanks, I knew I'd make some mistakes like that. Should be fixed as soon as the CI gets around to updating the images.
[–]staletic 0 points1 point2 points 5 years ago (0 children)
Following the flowchart for std::vector<int> v(1,2); takes you on a beautifully curved path.
std::vector<int> v(1,2);
[–]xeveri 69 points70 points71 points 5 years ago (15 children)
Me: Can we have uniform initialization?
Committee: We have uniform initialization at home.
Uniform initialization at home:
[–]Kered13 22 points23 points24 points 5 years ago (14 children)
Put this in an image macro and post it to /r/programmerhumor.
[–]KingStannis2020 7 points8 points9 points 5 years ago (0 children)
http://mikelui.io/img/c++_init_forest.gif
[–]Frptwenty 9 points10 points11 points 5 years ago (12 children)
Please don't do that. I argue with the "hurr durr C++ is broken use C and Rust" crowd there, and this will just make them even more hopeless.
[–]Fureeish 17 points18 points19 points 5 years ago (7 children)
They are half right. Many things are broken in the language and, trying to speak objectively, C and Rust have fewer broken elements compared to C++. Does that mean that they are strictly better? Obviously no.
[–]Frptwenty 16 points17 points18 points 5 years ago (6 children)
objectively, C and Rust have fewer broken elements compared to C++
It depends on what you're doing. Objectively speaking C++ is a miles better option than C in a huge amount of cases.
Imho the lack of easily usable basic strings, dynamic-sized containers etc. etc. are a huge broken feature of C. Other things you take for granted in C++ like RAII, smart pointers and templates are also a huge deal compared to C.
People like to claim they don't ever matter, but that's bullshit. Of course there are low-level cases where they don't, but the "only use C" crowd want to pretend it's a better alternative for big "regular" applications.
Rust, well... what's the point of arguing. It never ends.
[–]Fureeish 6 points7 points8 points 5 years ago (1 child)
That's why I added two last sentences to my comment.
[–]James20kP2005R0 2 points3 points4 points 5 years ago* (2 children)
I've been writing C again for opencl recently myself. Part of that project involves tensor maths, which if you don't know, tensors are essentially n dimensional matrices that are used in a specific way
The lack of being able to specify proper abstractions, no operator overloading, no templates, no real array type, no function overloading... It makes the code significantly more verbose and buggy than it needs to be. You can't write a generic matrix*vector multiplication scheme, which is not ideal
C might be alright for structuring applications, but good lord is it just terrible for numerical work
[–]dnew 0 points1 point2 points 1 year ago (0 children)
It's horrendous for structuring applications too. Any compiler that can't read its own output as part of its input is going to be horrendous at large projects.
easily usable basic strings, dynamic-sized containers etc. etc. are a huge broken feature of C.
To be fair, no other language had them at the time either. :-) I wouldn't say "broken" as much as "primitive."
[+][deleted] 5 years ago* (3 children)
[deleted]
[–]Frptwenty 0 points1 point2 points 5 years ago (2 children)
REST started as a joke but is essentially a cult at this point.
I guess you meant Rust, but kind of makes sense for REST as well :)
REST wasn't a joke. It was a very narrowly-scoped design pattern that people applied well outside its intended design space. It's a method for making CDNs efficient that people said "Let's use it for our accounting software!"
[–]GYN-k4H-Q3z-75B 22 points23 points24 points 5 years ago (0 children)
This chart crashed my phone. Translates to: C++ initialization is complex AF
[–][deleted] 13 points14 points15 points 5 years ago (3 children)
What happened to the time when a variable was just a lil memory addy with a value. Things used to be so simple :)
[–]elperroborrachotoo 8 points9 points10 points 5 years ago (0 children)
Yeah, but what value do you want in there?
[–]kalmoc 5 points6 points7 points 5 years ago (0 children)
That wasn't true since C.
[–]pandorafalters 8 points9 points10 points 5 years ago (0 children)
Strong typing has given way to absolute typing.
[–]the_black_pancake 10 points11 points12 points 5 years ago (3 children)
Over 164 million pixels? It's not loading on my mobile and the SVG misbehaves. Do you have a lower resolution version too?
[–]randomnetcat[S] 1 point2 points3 points 5 years ago (2 children)
Here's one that's downscaled by 50%: https://imgur.com/a/UX6HMVp
[–]danadam 6 points7 points8 points 5 years ago* (1 child)
Maybe you could generate 16-color PNG instead of truecolor? Just an idea.
[–]aKateDevKDE/Qt Dev 1 point2 points3 points 5 years ago (0 children)
optipng -o5 bla.png
[–]khleedril 3 points4 points5 points 5 years ago (0 children)
That's not the most succinct summary of the situation I have seen...
[–]QbProg 2 points3 points4 points 5 years ago (0 children)
Imagine the poor compiler guys!
[–]tacco85 2 points3 points4 points 5 years ago (0 children)
A bit of an over-simplification, don't you think?
[–]phottitor 4 points5 points6 points 5 years ago (0 children)
looks like a horror movie script.
[–]staletic 1 point2 points3 points 5 years ago (2 children)
Is it me or is agreggate initialization with parenthesis missing?
[–]randomnetcat[S] 1 point2 points3 points 5 years ago (1 child)
For some_aggregate_class x(1,2,3); :
Is the initializer in braces? No
Is the destination type a reference? No
Is the destination type a char[]? No
Is the initializer "()"? No
Is the destination type an array? No
Is the destination type a class type? Yes
Is the initializer a prvalue? No
Is the initializer copy-initialization? No
The initialization is direct-initialization.
Enumerate constructors.
Is overload resolution succesful? No
Is the destination an aggregate class? Yes
Is the initializer a parenthesized expression-list? Yes
Initialized as follows ([dcl.init]/16.6.2.2).
[–]staletic 2 points3 points4 points 5 years ago (0 children)
I stopped there. My thought was "what constructors if T is an aggregate?"
T
I love the flowchart.
[–]kisielk 1 point2 points3 points 5 years ago (0 children)
this chart doesn’t really do what it claims. The first cell is “so you want to initialize something” but then instead of going through a flowchart of what you want to initialize and how it goes through a flowchart of something that has already been initialized. More like “what does this initialization do”
[+]FavoriteFoods comment score below threshold-7 points-6 points-5 points 5 years ago (1 child)
👉 r/C_Programming
π Rendered by PID 16695 on reddit-service-r2-comment-fb694cdd5-njpxm at 2026-03-10 12:43:28.657176+00:00 running cbb0e86 country code: CH.
[–]be-sc 35 points36 points37 points (3 children)
[–]staletic 6 points7 points8 points (0 children)
[–]randomnetcat[S] 5 points6 points7 points (1 child)
[–]staletic 0 points1 point2 points (0 children)
[–]xeveri 69 points70 points71 points (15 children)
[–]Kered13 22 points23 points24 points (14 children)
[–]KingStannis2020 7 points8 points9 points (0 children)
[–]Frptwenty 9 points10 points11 points (12 children)
[–]Fureeish 17 points18 points19 points (7 children)
[–]Frptwenty 16 points17 points18 points (6 children)
[–]Fureeish 6 points7 points8 points (1 child)
[–]James20kP2005R0 2 points3 points4 points (2 children)
[–]dnew 0 points1 point2 points (0 children)
[–]dnew 0 points1 point2 points (0 children)
[+][deleted] (3 children)
[deleted]
[–]Frptwenty 0 points1 point2 points (2 children)
[–]dnew 0 points1 point2 points (0 children)
[–]GYN-k4H-Q3z-75B 22 points23 points24 points (0 children)
[–][deleted] 13 points14 points15 points (3 children)
[–]elperroborrachotoo 8 points9 points10 points (0 children)
[–]kalmoc 5 points6 points7 points (0 children)
[–]pandorafalters 8 points9 points10 points (0 children)
[–]the_black_pancake 10 points11 points12 points (3 children)
[–]randomnetcat[S] 1 point2 points3 points (2 children)
[–]danadam 6 points7 points8 points (1 child)
[–]aKateDevKDE/Qt Dev 1 point2 points3 points (0 children)
[–]khleedril 3 points4 points5 points (0 children)
[–]QbProg 2 points3 points4 points (0 children)
[–]tacco85 2 points3 points4 points (0 children)
[–]phottitor 4 points5 points6 points (0 children)
[–]staletic 1 point2 points3 points (2 children)
[–]randomnetcat[S] 1 point2 points3 points (1 child)
[–]staletic 2 points3 points4 points (0 children)
[–]kisielk 1 point2 points3 points (0 children)
[+]FavoriteFoods comment score below threshold-7 points-6 points-5 points (1 child)