私は、次のクラステンプレートを持っている:部分テンプレート特殊化SFINAE
template<bool head, bool... tail>
struct var_and {
static constexpr bool value = head && var_and<tail...>::value;
};
template<bool b> struct var_and<b> {
static constexpr bool value = b;
};
template<typename... Ts>
struct type_list {};
template <typename T, typename Enable = void>
class foo;
template <typename... T>
class foo<type_list<T...>, std::enable_if_t<var_and<std::is_integral_v<T>...>::value>> {};
私は専門一致させよう:で
Error C2079 'test' uses undefined class 'ECS::foo<ECS::type_list<int,int,int>,void>'
:私はエラーを取得する
foo<type_list<int, int, int>> test{};
を私はこれらのエラーを得ると同時に:
more than one partial specialization matches the template argument list of class "ECS::foo<ECS::type_list<int, int, int>, void>"
"ECS::foo<ECS::type_list<T...>, std::enable_if_t<ECS::var_and<std::is_integral_v<T>...>::value, void>>"
"ECS::foo<ECS::type_list<T...>, std::enable_if_t<ECS::var_and<std::is_integral_v<T>...>::value, void>>"
... (The exact same error message 6 more times)
SFINAEを使用して、variadic型パックの型の型特性を具体的に実行するにはどうすればよいですか?
私は何の問題は、単一の型引数のために働くことを得るがありませんでした: http://www.cppsamples.com/common-tasks/class-template-sfinae.html
それがなくても可能であるならば、私は、私は単にstatic_assertを使用することができます知っているが、私は思っていました。次のように
あなたがMSVCを使用しているようで、コンパイラの出力から。このコードはgccとclangで完璧に動作します(http://coliru.stacked-crooked.com/a/36b9eecd91763aafを参照)...だから、msvcバグ?どちらか、それともコンパイルされているすべてのコードを与えていないか:) – Rerito
msvcでコンパイルされたこの正確なコードは、同じエラー(http://rextester.com/NIU85113)を返します。だから私はそれがバグだと仮定していますか? –
実際に、私はリンクがわずかに異なるエラーを表示するようになったことに気付きました。 http://webcompiler.cloudapp.net/で同じコードが実行されても同じエラーが発生し、より新しいコンパイラを使用します。 –