has_virtual_destructor 類別
測試,如果型別具有虛擬解構函式。
template<class Ty>
struct has_virtual_destructor;
參數
- Ty
查詢的型別。
備註
這個型別述詞的執行個體之型別,則 Ty 是有虛擬解構函式的類別,否則它保留 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::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