has_virtual_destructor 类
测试,如果类型具有虚析构函数。
template<class Ty>
struct has_virtual_destructor;
参数
- Ty
查询的类型。
备注
谓词应用类型的实例,则 Ty 类型是具有虚析构函数的类,否则它对负错误。
示例
// 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);
}
要求
标头: <type_traits>
命名空间: std