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

时间:2016-04-21 00:04:40

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

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

我认为我的构造函数不应该接受任何参数并传递enable_if检查 - 但是某个地方VS正在说" no"。

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;  
}

1 个答案:

答案 0 :(得分:1)

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

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