Partager via


is_abstract Class

 

The latest version of this topic can be found at is_abstract Class.

Tests if type is abstract class.

Syntax

template <class Ty>  
struct is_abstract;  

Parameters

Ty
The type to query.

Remarks

An instance of the type predicate holds true if the type Ty is a class that has at least one pure virtual function, otherwise it holds false.

Example

// std_tr1__type_traits__is_abstract.cpp   
// compile with: /EHsc   
#include <type_traits>   
#include <iostream>   
  
struct trivial   
    {   
    int val;   
    };   
  
struct abstract   
    {   
    virtual int val() = 0;   
    };   
  
int main()   
    {   
    std::cout << "is_abstract<trivial> == " << std::boolalpha   
        << std::is_abstract<trivial>::value << std::endl;   
    std::cout << "is_abstract<abstract> == " << std::boolalpha   
        << std::is_abstract<abstract>::value << std::endl;   
  
    return (0);   
    }  
  
is_abstract<trivial> == false  
is_abstract<abstract> == true  

Requirements

Header: <type_traits>

Namespace: std

See Also

<type_traits>
is_polymorphic Class