Error del compilador C3206
'function': argumento de tipo no válido para 'param', falta la lista de argumentos de tipo en el tipo de clase 'typename'
Una plantilla de función se define como tomar un argumento de tipo de plantilla. Sin embargo, se pasó un argumento de plantilla.
El ejemplo siguiente genera la advertencia 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> >();
}
Posible solución:
// C3206b.cpp
// compile with: /c
template <class T>
void f() {}
template <class T>
struct S {};
void f1() {
f<S<int> >();
}
También se puede producir el error C3206 al usar genéricos:
// C3206c.cpp
// compile with: /clr
generic <class GT1>
void gf() {}
generic <class T>
value struct GS {};
int main() {
gf<GS>(); // C3206
}
Posible solución:
// C3206d.cpp
// compile with: /clr
generic <class GT1>
void gf() {}
generic <class T>
value struct GS {};
int main() {
gf<GS<int> >();
}
No se permite una plantilla de clase como argumento de tipo de plantilla. El ejemplo siguiente genera la advertencia 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.
}
Posible solución:
// C3206f.cpp
template <class T>
struct S {};
template <class T>
void func() { // takes a type
T t;
}
int main() {
func<S<int> >();
}
Si es necesario un parámetro de plantilla template, debe ajustar la función en una clase de plantilla que toma un parámetro de plantilla 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();
}