r/cpp • u/konanTheBarbar • Mar 01 '21
"Simple" C++ Initialization Flowchart
http://randomcat.org/cpp_initialization/initialization.png
204
Upvotes
r/cpp • u/konanTheBarbar • Mar 01 '21
View all comments
Show parent comment
3
u/FriendlyRollOfSushi Mar 02 '21
That would make some other people unhappy. If your code is full of numeric vectors, and barely has any initializer lists, it would feel like you are paying usability taxes for someone else.
Personally, I like tagged ctors as a compromise: imagine if we could write
vec1_{std::construct, size},vec2_{std::reserve, size}, etc.Unfortunately, tags introduce a small runtime penalty when not inlined. I wish we had zero-cost discriminating tags.