相当简单的问题,
auto x11 {1,2,3,4};
auto x1 = {1,2,3,4};
auto x22 {1.0, 2.25, 3.5};
auto x2 = {1.0, 2.25, 3.5};
据我了解,这里应该没有什么区别=
或不。但是,使用 llvm/clang 6.0.0 (使用 --std=c++17),我得到:
main1.cpp:35:17: error: initializer for variable 'x11' with type 'auto' contains multiple
expressions
auto x11 {1,2,3,4};
~~~~~~~~ ^
main1.cpp:37:20: error: initializer for variable 'x22' with type 'auto' contains multiple
expressions
auto x22 {1.0, 2.25, 3.5};
来自 Stroustroup 的 C++ 书,第 162 页:
auto x1 {1,2,3,4}; // x1 is an initializer_list<int>
auto x2 {1.0, 2.25, 3.5 }; // x2 is an initializer_list of<double>
那么,不这样做真的有问题吗?=在那里?