次の方法で共有


has_nothrow_copy クラス

コピーによる構築で例外がスローされない型であるかどうかをテストします。

template<class Ty>
    struct has_nothrow_copy;

パラメーター

  • Ty
    問い合わせる型。

解説

型 Ty が nothrow のコピー コンストラクターを持つ場合、型述語のインスタンスは true を保持します。それ以外の場合は、false を保持します。

使用例

 

// std_tr1__type_traits__has_nothrow_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_nothrow_copy<trivial> == " << std::boolalpha 
        << std::has_nothrow_copy<trivial>::value << std::endl; 
    std::cout << "has_nothrow_copy<throws> == " << std::boolalpha 
        << std::has_nothrow_copy<throws>::value << std::endl; 
 
    return (0); 
    } 
 
  

必要条件

ヘッダー : <type_traits>

名前空間: std

参照

関連項目

<type_traits>

has_trivial_copy クラス

その他の技術情報

<type_traits> メンバー