Expand Minimize

has_nothrow_assign Class

Tests if type doesn't throw on assign.

template<class Ty>
    struct has_nothrow_assign;

Ty

The type to query.

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

A nothrow function is a function that has an empty throw specifier, or a function which the compiler can otherwise determine will not throw an exception.

 

// std_tr1__type_traits__has_nothrow_assign.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_assign<trivial> == " << std::boolalpha 
        << std::has_nothrow_assign<trivial>::value << std::endl; 
    std::cout << "has_nothrow_assign<throws> == " << std::boolalpha 
        << std::has_nothrow_assign<throws>::value << std::endl; 
 
    return (0); 
    } 
 
has_nothrow_assign<trivial> == true
has_nothrow_assign<throws> == false

Header: <type_traits>

Namespace: std

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft