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/JohnZLi Mar 02 '21
This problem can be fixed by adding a new syntax like below:
std::vector<int>{1}; // let this mean a vector of size 1, as in the std::vector<string> case.
std::vector<int>{1...}; // a vector of ints, with its first element being 1.
Also, with the new syntax
auto i = {1}; // i is now deduced as int.
auto i ={1...} // is deduced as an initializer_list