Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ multiple versions of a defaulted special member functions -- error in MSVC 2015

The following simple code produces an error in the newest Visual Studio compiler (MSVC 2015 Update 2):

struct Foo
{
    template<typename ... Args, typename = std::enable_if_t<sizeof...(Args) != 0> > 
    Foo(Args ...) {}
    Foo() = default;  // error

    //Foo() {}        //this works!
};

The error message is

error C2580: 'Foo::Foo(void)': multiple versions of a defaulted special member functions are not allowed

gcc accepts it without any problems.

This seems to me as an obvious bug (in the sense that it is not supported by the standard). Any other views?

like image 385
davidhigh Avatar asked Apr 15 '16 21:04

davidhigh


1 Answers

This is a bug in VS 2015 Update 2. We've already fixed the bug (202164, though that's an internal bug number.) This code should work in Update 3 builds.

like image 144
apardoe Avatar answered Oct 04 '22 14:10

apardoe