Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

has_virtual_destructor Class

Tests if type has virtual destructor.

template<class Ty>
    struct has_virtual_destructor;

Ty

The type to query.

An instance of the type predicate holds true if the type Ty is a class that has a virtual destructor, otherwise it holds false.

 

// std_tr1__type_traits__has_virtual_destructor.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 << "has_virtual_destructor<trivial> == " << std::boolalpha 
        << std::tr1::has_virtual_destructor<trivial>::value << std::endl; 
    std::cout << "has_virtual_destructor<throws> == " << std::boolalpha 
        << std::tr1::has_virtual_destructor<throws>::value << std::endl; 
 
    return (0); 
    } 
 
has_virtual_destructor<trivial> == false has_virtual_destructor<throws> == true

Header: <type_traits>

Namespace: std::tr1

Community Additions

ADD
Show:
© 2015 Microsoft