C++ 多个版本的默认特殊成员函数——MSVC 2015 中的错误

标签 c++ visual-c++ visual-studio-2015

以下简单代码在 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/

相关文章:

c++ - 代码分析在 VS 2010 中不起作用

C++ 没有函数模板的实例

visual-studio - 如何在 Visual Studio TFS API (VS2015) 中将工作项关联为 "Associate"或 "Resolve"?

c++ - Visual Studio 2015 重复构建时卡住整个 PC

c++ - 让 GDB 保存断点列表

c++ - 如何在 C++ 中的同一函数中使用字符串和 double

visual-c++ - 分析 Visual C++ 链接时间

c++ - C++中的异常被捕获后找出源头?

c++ - 如何在 Visual Studio C++ 11 运行时定义二维数组?

c# - 无法在 VS2015 中运行 NuGet 包命令