has_nothrow_copy Class

Tests if type doesn't throw on copy construction.

template<class Ty>
    struct has_nothrow_copy;

Parameters

  • Ty
    The type to query.

Remarks

An instance of the type predicate holds true if the type Ty has a nothrow copy constructor, otherwise it holds false.

Example

 

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

has_nothrow_copy<trivial> == true has_nothrow_copy<throws> == false

Requirements

Header: <type_traits>

Namespace: std::tr1

See Also

Reference

<type_traits>

has_trivial_copy Class