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) (desde C++26)
copyable_function & operator = ( copyable_function && other ) ;
(2) (desde C++26)
copyable_function & operator = ( std:: nullptr_t ) noexcept ;
(3) (desde C++26)
template < class F >
copyable_function & operator = ( F && f ) ;
(4) (desde C++26)

Asigna un nuevo destino a std::copyable_function o destruye su destino.

1) Asigna una copia del objetivo de other a * this como si se ejecutara auto ( other ) . swap ( * this ) .
2) Mueve el objetivo de other a * this o destruye el objetivo de * this (si existe) si other está vacío, mediante auto ( std :: move ( other ) ) . swap ( * this ) . other queda en un estado válido con un valor no especificado después de la asignación de movimiento.
3) Destruye el objetivo actual si existe. * this está vacío después de la llamada.
4) Establece el objetivo de * this al invocable f , o destruye el objetivo actual si f es un puntero de función nulo, un puntero nulo a función miembro, o un std::copyable_function vacío, como si se ejecutara copyable_function ( std:: forward < F > ( f ) ) . swap ( * this ) ; . Esta sobrecarga participa en la resolución de sobrecargas solo si el constructor de copyable_function desde F participa en la resolución de sobrecargas. El programa está mal formado o tiene comportamiento indefinido si la llamada al constructor seleccionado está mal formada o tiene comportamiento indefinido.

Contenidos

Parámetros

other - otro objeto std::copyable_function para copiar o mover el objetivo de
f - un objeto invocable para inicializar el nuevo objetivo con

Valor de retorno

* this

Ejemplo

Véase también

asigna un nuevo objetivo
(función miembro pública de std::function<R(Args...)> )
reemplaza o destruye el objetivo
(función miembro pública de std::move_only_function )