()和{}构造对象之间有什么区别?
我认为{}应该只支持with initializer_list或array,但是当我在snip之下运行时,我感到困惑。
#include <iostream>
using namespace std;
struct S {
    int v=0;
    S(int l) : v(l) {
    }
};
int main()
{
    S s1(12); // statement1
    S s2{12}; // statement2
    cout << s1.v << endl;
    cout << s2.v << endl;
}
statement1是正确的,因为这()是构造对象的基本语法。
我希望statement2将编译失败。我认为{}只能用于数组或initializer_list类型。但是实际结果可以完美编译而不会出错。
我怎么了