C&C++   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了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

大佬总结

以上是大佬教程为你收集整理的c – 变量args SFINAE默认构造函数在clang中工作,但在Visual Studio 2015中失败全部内容,希望文章能够帮你解决c – 变量args SFINAE默认构造函数在clang中工作,但在Visual Studio 2015中失败所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。