has_nothrow_copy 类

测试,如果类型在复制构造不引发。

template<class Ty>
    struct has_nothrow_copy;

参数

  • Ty
    查询的类型。

备注

谓词应用类型的实例,则 Ty 类型是具有复制构造函数,否则它对负错误。

示例

 

// 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 成员