以下简单代码在 newest Visual Studio compiler 中产生错误(MSVC 2015 更新 2):
struct Foo
{
template<typename ... Args, typename = std::enable_if_t<sizeof...(Args) != 0> >
Foo(Args ...) {}
Foo() = default; // error
//Foo() {} //this works!
};
错误信息是
error C2580: 'Foo::Foo(void)': multiple versions of a defaulted special member functions are not allowed
gcc接受它没有任何问题。
在我看来,这是一个明显的错误(从某种意义上说,它不受标准支持)。还有其他意见吗?
最佳答案
这是 VS 2015 Update 2 中的错误。我们已经修复了该错误(202164,尽管这是一个内部错误编号。)此代码应该适用于 Update 3 版本。
关于C++ 多个版本的默认特殊成员函数——MSVC 2015 中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36657243/