Класс is_polymorphic

Проверяет, есть ли у типа виртуальная функция.

Синтаксис

template <class Ty>
struct is_polymorphic;

Параметры

Ty
Запрашиваемый тип.

Замечания

Экземпляр предиката типа имеет значение true, если тип Ty является классом, который объявляет или наследует виртуальную функцию, в противном случае она содержит значение false.

Пример

// 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

Требования

Заголовок:<type_traits>

Пространство имен: std

См. также

<type_traits>
Класс is_abstract