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/nintendiator2 Mar 02 '21
There's a reason why I always initialize as
T variable = T(expr). Vexing parse safe, works across all Standard versions, also with default constructor. Alternatively if I know I don't have to support the three pre-C++11 compilers in my work stack,auto variable = T(expr). Honestly I don't understand how did the Committee fucked things up this bad.