Classe is_polymorphic

Verifica se il tipo ha una funzione virtuale.

Sintassi

template <class Ty>
struct is_polymorphic;

Parametri

Ty
Tipo su cui eseguire una query.

Osservazioni:

Un'istanza del predicato di tipo contiene true se il tipo Ty è una classe che dichiara o eredita una funzione virtuale, altrimenti contiene false.

Esempio

// std__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);
    }
is_polymorphic<trivial> == false
is_polymorphic<throws> == true

Requisiti

Intestazione:<type_traits>

Spazio dei nomi: std

Vedi anche

<type_traits>
Classe is_abstract