编译器错误 C3230
“function”:“template”的模板类型参数不能包含泛型类型参数:“param”
模板在编译时实例化,而泛型在运行时实例化。 因此,不能生成可调用模板的泛型代码,因为当泛型类型在最后才已知时,模板不能在运行时实例化。
以下示例生成 C3230:
// C3230.cpp
// compile with: /clr /LD
template <class S>
void f(S t);
generic <class U>
ref class C {
void f1(U x) {
f(x); // C3230
}
};