has_virtual_destructor クラス

更新 : 2007 年 11 月

型に仮想デストラクタが存在するかどうかをテストします。

template<class Ty>
    struct has_virtual_destructor;

パラメータ

  • Ty
    問い合わせる型。

解説

型 Ty が仮想デストラクタを持ったクラスである場合、型述語のインスタンスは true を保持します。それ以外の場合は、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

必要条件

ヘッダー : <type_traits>

名前空間 : std::tr1

参照

参照

<type_traits>

has_trivial_destructor クラス