Are ={} and {}-style initializations the same in C++11?
问题 C++11 introduced {}-style initializations. But are these two forms T x {...}; T x = {...}; the same? 回答1: They are not exactly the same. Maybe this can be illustrated by a counter-example: struct Foo { explicit Foo(std::initializer_list<int>) {} }; int main() { Foo f0{1, 2, 3}; // OK Foo f1 = {1, 2, 3}; // ERROR } So, the second variant requires that the type be implicitly constructable from an initialization list, whereas the first version doesn't. Note that the same applies for constructors