Namespaces
Variants

std::copyable_function:: operator=

From cppreference.net
Utilities library
Function objects
Function invocation
(C++17) (C++23)
Identity function object
(C++20)
Old binders and adaptors
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
( until C++17* ) ( until C++17* )
( until C++17* ) ( until C++17* )

( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
copyable_function & operator = ( const copyable_function & other ) ;
(1) (depuis C++26)
copyable_function & operator = ( copyable_function && other ) ;
(2) (depuis C++26)
copyable_function & operator = ( std:: nullptr_t ) noexcept ;
(3) (depuis C++26)
template < class F >
copyable_function & operator = ( F && f ) ;
(4) (depuis C++26)

Attribue une nouvelle cible à std::copyable_function ou détruit sa cible.

1) Attribue une copie de la cible de other à * this comme si en exécutant auto ( other ) . swap ( * this ) .
2) Déplace la cible de other vers * this ou détruit la cible de * this (si elle existe) si other est vide, via auto ( std :: move ( other ) ) . swap ( * this ) . other se trouve dans un état valide avec une valeur non spécifiée après l'affectation par déplacement.
3) Détruit la cible actuelle si elle existe. * this est vide après l'appel.
4) Définit la cible de * this comme étant l'objet appelable f , ou détruit la cible actuelle si f est un pointeur de fonction nul, un pointeur nul vers une fonction membre, ou un std::copyable_function vide, comme en exécutant copyable_function ( std:: forward < F > ( f ) ) . swap ( * this ) ; . Cette surcharge participe à la résolution de surcharge uniquement si le constructeur de copyable_function à partir de F participe à la résolution de surcharge. Le programme est mal formé ou a un comportement indéfini si l'appel du constructeur sélectionné est mal formé ou a un comportement indéfini.

Table des matières

Paramètres

other - un autre objet std::copyable_function à copier ou déplacer la cible de
f - un objet appelable pour initialiser la nouvelle cible avec

Valeur de retour

* this

Exemple

Voir aussi

assigne une nouvelle cible
(fonction membre publique de std::function<R(Args...)> )
remplace ou détruit la cible
(fonction membre publique de std::move_only_function )