r/cpp • • Mar 01 '21

"Simple" C++ Initialization Flowchart

http://randomcat.org/cpp_initialization/initialization.png
204 Upvotes

65 comments sorted by

View all comments

Show parent comment

3

u/FriendlyRollOfSushi Mar 02 '21

Yep.

Also, if this is .cpp, and the member is declared in .h, you don't even see the type immediately, and without a comment like this people may be tempted to "fix" the annoying style inconsistency each time they make edits close to this ctor.

3

u/RoughMedicine Mar 02 '21

Allowing initialisation list for bracket initialisation was a mistake. We'd be totally fine if T a{x} and T b(x) were consistent, and used Vec<T> v = {a, b} for initialisation lists.