Export (0) Print
Expand All
Expand Minimize

is_abstract Class

Tests if type is abstract class.

template<class Ty>
    struct is_abstract;

Ty

The type to query.

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.

 

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

Header: <type_traits>

Namespace: std

Show:
© 2014 Microsoft