r/cpp • u/konanTheBarbar • Mar 01 '21
"Simple" C++ Initialization Flowchart
http://randomcat.org/cpp_initialization/initialization.png48
u/GYN-k4H-Q3z-75B Mar 01 '21
C++ initialization
Simple
Choose one.
26
3
Mar 01 '21
Desperately trying not to be sarcy and say "You accidentally wrote initialisation there too". But failed. C'est la vie 🤷♀️
Well, the kinds of languages that people complain about, etc.
17
Mar 01 '21
Here is the ledgible version http://randomcat.org/cpp_initialization/initialization.svg
5
4
3
3
u/CenterOfMultiverse Mar 02 '21
Never understood what's the point of explicit initializations not in arguments. How
auto s = std::string{"view"sv};or
std::string s{"view"sv};are supposed to help, where
std::string s = "view"sv;couldn't?
2
3
0
103
u/atimholt Mar 01 '21
I prefer it as a table.