为什么 constexpr 不能应用于构造函数?
以下代码不能用VC++ 2013 CTP编译。
struct A
{
constexpr A()
: _n(5)
{}
int _n;
};
constexpr A f()
{
return A();
}
int main()
{
auto a = f();
}
error C3757: 'A': type not allowed for 'constexpr' function
最佳答案
VC 2013 尚不支持所有 C++11 功能。看 MSDN list .
关于c++ - 为什么 constexpr 不能应用于构造函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21878345/