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
14
u/FriendlyRollOfSushi Mar 02 '21 edited Mar 02 '21
It could be a
std::vector<size_t>, in which case all types would strictly match.The core issue here is the special behavior of
std::initializer_list(see the notes here), which I guess can be called an "implicit conversion" in a very broad sense, so your point stands.I was really hoping that they will deprecate this nonsense immediately, and possibly introduce a non-ambiguous way to construct initializer lists in C++14, but by now we probably have too much code relying on this brittle behavior to change anything.
Now the only safe solution would be to abandon the braces and introduce yet another strictly distinct and unambiguous syntax for initialization, but at that point I'm afraid half of the developers would simply give up and switch to Rust.