is_polymorphic-Klasse
Testet, ob Typ eine virtuelle Funktion verfügt.
template<class Ty>
struct is_polymorphic;
Parameter
- Ty
Der Typ in Abfragen.
Hinweise
Eine Instanz der Typprädikatgriffe true, wenn der Ty-Typ eine Klasse ist, die einer virtuellen Funktion deklariert oder erbt; andernfalls false hält er an.
Beispiel
// std_tr1__type_traits__is_polymorphic.cpp
// compile with: /EHsc
#include <type_traits>
#include <iostream>
struct trivial
{
int val;
};
struct throws
{
throws() throw(int)
{
}
throws(const throws&) throw(int)
{
}
throws& operator=(const throws&) throw(int)
{
}
virtual ~throws()
{
}
int val;
};
int main()
{
std::cout << "is_polymorphic<trivial> == " << std::boolalpha
<< std::is_polymorphic<trivial>::value << std::endl;
std::cout << "is_polymorphic<throws> == " << std::boolalpha
<< std::is_polymorphic<throws>::value << std::endl;
return (0);
}
Anforderungen
Header: <type_traits>
Namespace: std