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