Partager via


has_nothrow_assign, classe

Teste si le type ne lève pas une exception lors de l'assignation.

template<class Ty>
    struct has_nothrow_assign;

Paramètres

  • Ty
    Type à interroger.

Notes

Une instance de l'attribut de type contient la valeur true si le type Ty a un opérateur d'assignation de copie nothrow, sinon il contient FALSE.

Une fonction nothrow est une fonction qui a un spécificateur throw vide, ou une fonction que le compilateur peut déterminer qu'elle ne lève pas d'exception.

Exemple

 

// 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); 
    } 
 
  

Configuration requise

En-tête : <type_traits>

Espace de noms : std

Voir aussi

Référence

<type_traits>

has_trivial_assign, classe

Autres ressources

<type_traits> membres