c – 变量args SFINAE默认构造函数在clang中工作,但在Visual Studio 2015中失败

任何人都知道这段代码是坏的还是VS有错误或者Clang是否允许?

我认为我的构造函数应该不接受任何参数并传递enable_if检查 – 但在某处VS说“不”.

Visual Studio 2015 Update 2出现以下错误:

source_file.cpp(##): error C2512: 'Foo::Foo': no appropriate default constructor available

clang live:http://rextester.com/VWAI2954

VS有错误:http://rextester.com/PTDSS2853

#include <iostream>
#include <deque>
using namespace std;


template <bool... b> struct static_all_of;

// If the first parameter is true, look at the rest of the list
template <bool... tail>
struct static_all_of<true, tail...> : static_all_of<tail...> {};

// if any parameter is false, return false
template <bool... tail>
struct static_all_of<false, tail...> : std::false_type {};

// If there are no parameters left, no false was found so return true
template <> struct static_all_of<> : std::true_type {};



struct Bar{};

struct Foo {

 template <class... Things,
  std::enable_if_t<static_all_of<std::is_base_of<Bar, std::remove_pointer_t<Things>>::value...>::value, int> = 0>
   Foo(Things... stuff){}
};

int main()
{
    Foo f;  
}

最佳答案 正如deviantfan所说 – 实际上MS没有声称Visual Studio 2015实际上有适当的SFINAE支持,所以这似乎不是一个特定的错误,只是VS2015不符合C 11.

https://msdn.microsoft.com/en-us/library/hh567368.aspx

点赞