Export (0) Print
Expand All
Expand Minimize

has_trivial_assign Class

Tests if type has trivial assign.

template<class Ty>
    struct has_trivial_assign;

Ty

The type to query.

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

A copy assignment operator for a class Ty is trivial if:

it is implicitly declared

the class Ty has no virtual functions

the class Ty has no virtual bases

all the direct bases of the class Ty have trivial copy assignment operators

the classes of all the non-static data members of class type have trivial copy assignment operators

the classes of all the non-static data members of type array of class have trivial copy assignment operators

 

// std_tr1__type_traits__has_trivial_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_trivial_assign<trivial> == " << std::boolalpha 
        << std::has_trivial_assign<trivial>::value << std::endl; 
    std::cout << "has_trivial_assign<throws> == " << std::boolalpha 
        << std::has_trivial_assign<throws>::value << std::endl; 
 
    return (0); 
    } 
 
has_trivial_assign<trivial> == true
has_trivial_assign<throws> == false

Header: <type_traits>

Namespace: std

Show:
© 2014 Microsoft