4 ms·
Yes, but never use {} initialization with auto.
by thecpphorse 10y ago
Yes, but never use {} initialization with auto.
- clishem 10y agoNever give advice without telling why, because it's very likely that people will forget it if they don't understand your advice.
- thecpphorse 10y agoOk. auto i{42}; // std::initializer_list<int>
- david-given 10y agoBut why is that bad?
- lmitchell 10y agoBecause `i` isn't an int, it's an initializer_list, and you almost never want to actually create an initializer_list instead of an int? Seems pretty understandable to me.
- thecpphorse 10y agoIt's unexpected. Nobody ever* wanted to assign an initializer list to a named variable. [*] pretty much
- hellofunk 10y agoNo longer applies with c++17