Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Tests if type has virtual destructor.
template<class Ty>
struct has_virtual_destructor;
Parameters
- Ty
The type to query.
Remarks
An instance of the type predicate holds true if the type Ty is a class that has a virtual destructor, otherwise it holds false.
Example
// 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::has_virtual_destructor<trivial>::value << std::endl;
std::cout << "has_virtual_destructor<throws> == " << std::boolalpha
<< std::has_virtual_destructor<throws>::value << std::endl;
return (0);
}
has_virtual_destructor<trivial> == false has_virtual_destructor<throws> == true
Requirements
Header: <type_traits>
Namespace: std