has_trivial_copy クラス

更新 : 2007 年 11 月

型に自明なコピー コンストラクタが存在するかどうかをテストします。

template<class Ty>
    struct has_trivial_copy;

パラメータ

  • Ty
    照会する型。

解説

型 Ty が自明なコピー コンストラクタを持ったクラスである場合、型述語のインスタンスは true を保持します。それ以外の場合は、false を保持します。

クラス Ty のコピー コンストラクタは、次の条件を満たしていれば、自明なコピー コンストラクタです。

暗黙的に宣言されている。

クラス Ty に仮想関数が存在しない。

クラス Ty に仮想基本クラスが存在しない。

クラス Ty のすべての直接基本クラスに、自明なコピー コンストラクタが存在する。

クラス型のすべての非静的データ メンバのクラスに自明なコピー コンストラクタが存在する。

クラスの配列型のすべての非静的データ メンバのクラスに自明なコピー コンストラクタが存在する。

使用例

 

// std_tr1__type_traits__has_trivial_copy.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) 
        { 
        } 
 
    int val; 
    }; 
 
int main() 
    { 
    std::cout << "has_trivial_copy<trivial> == " << std::boolalpha 
        << std::tr1::has_trivial_copy<trivial>::value << std::endl; 
    std::cout << "has_trivial_copy<throws> == " << std::boolalpha 
        << std::tr1::has_trivial_copy<throws>::value << std::endl; 
 
    return (0); 
    } 
 
has_trivial_copy<trivial> == true
has_trivial_copy<throws> == false

必要条件

ヘッダー : <type_traits>

名前空間 : std::tr1

参照

参照

<type_traits>

has_nothrow_copy クラス