Compiler Error C2139
Visual Studio 2015
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Compiler Error C2139.
type' : an undefined class is not allowed as an argument to compiler intrinsic type trait 'trait'
An invalid argument was passed to a type trait.
For more information, see Compiler Support for Type Traits.
The following sample generates C2139.
// C2139.cpp
// compile with: /EHsc
#include <iostream>
using namespace std;
template <class T>
struct is_polymorphic {
static const bool value = __is_polymorphic(T);
};
class C;
class D {};
class E {
public:
virtual void Test() {}
};
int main() {
cout << is_polymorphic<C>::value << endl; // C2139
cout << is_polymorphic<D>::value << endl; // OK
cout << is_polymorphic<E>::value << endl; // OK
}
Show: