Compiler Error C2140
'type' : a type that is dependent on a generic type parameter is not allowed as an argument to compiler intrinsic type trait 'trait'
An invalid type specifier was passed to a type trait.
For more information, see Compiler Support for Type Traits.
Example
The following sample generates C2140.
// C2140.cpp
// compile with: /clr /c
template <class T>
struct is_polymorphic {
static const bool value = __is_polymorphic(T);
};
class x {};
generic <class T>
ref class C {
void f() {
System::Console::WriteLine(__is_polymorphic(T)); // C2140
System::Console::WriteLine(is_polymorphic<T>::value); // C2140
System::Console::WriteLine(__is_polymorphic(x)); // OK
System::Console::WriteLine(is_polymorphic<x>::value); // OK
}
};