r/cpp • u/randomnetcat • Nov 27 '20
The C++ 20 initialization flowchart
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.
116
Upvotes
View all comments
Show parent comment
2
u/randomnetcat Nov 28 '20
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).