'function': 'param' の型引数が無効です。クラス型 'typename' の型引数リストがありません
関数テンプレートは、テンプレート型引数を受け取ると定義されます。 しかし、テンプレート template 引数が渡されました。
次の例では C3206 が生成されます。
// C3206.cpp
template <class T>
void f() {}
template <class T>
struct S {};
void f1() {
f<S>(); // C3206
// try the following line instead
// f<S<int> >();
}
考えられる解決方法:
// C3206b.cpp
// compile with: /c
template <class T>
void f() {}
template <class T>
struct S {};
void f1() {
f<S<int> >();
}
C3206 は、ジェネリックを使用しているときも発生します。
// C3206c.cpp
// compile with: /clr
generic <class GT1>
void gf() {}
generic <class T>
value struct GS {};
int main() {
gf<GS>(); // C3206
}
考えられる解決方法:
// C3206d.cpp
// compile with: /clr
generic <class GT1>
void gf() {}
generic <class T>
value struct GS {};
int main() {
gf<GS<int> >();
}
クラス テンプレートは、テンプレート型引数として許可されません。 次の例では C3206 が生成されます:
// C3206e.cpp
template <class T>
struct S {};
template <class T>
void func() { // takes a type
T<int> t;
}
int main() {
func<S>(); // C3206 S is not a type.
}
考えられる解決方法:
// C3206f.cpp
template <class T>
struct S {};
template <class T>
void func() { // takes a type
T t;
}
int main() {
func<S<int> >();
}
テンプレート template パラメーターが必要な場合は、テンプレート template パラメーターを受け取るテンプレート クラスに関数をラップする必要があります:
// C3206g.cpp
template <class T>
struct S {};
template<template<class> class TT>
struct X {
static void func() {
TT<int> t1;
TT<char> t2;
}
};
int main() {
X<S>::func();
}