Namespaces
Variants

std::move_only_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* )
move_only_function & operator = ( move_only_function && other ) ;
(1) (C++23 이후)
move_only_function & operator = ( const move_only_function & ) = delete ;
(2) (C++23 이후)
move_only_function & operator = ( std:: nullptr_t ) noexcept ;
(3) (C++23 이후)
template < class F >
move_only_function & operator = ( F && f ) ;
(4) (C++23 이후)

std::move_only_function 에 새로운 대상을 할당하거나 대상을 파괴합니다.

1) other 의 대상을 * this 로 이동시키거나, other 가 비어 있는 경우 * this 의 대상(존재하는 경우)을 파괴합니다. 이는 auto ( std :: move ( other ) ) . swap ( * this ) 를 통해 수행됩니다. other 는 이동 할당 후 지정되지 않은 값을 가진 유효한 상태에 있습니다.
2) 복사 할당 연산자가 삭제되었습니다. std::move_only_function CopyAssignable 요구 사항을 충족하지 않습니다.
3) 현재 대상이 존재하는 경우 이를 파괴합니다. * this 는 호출 후 비어 있게 됩니다.
4) * this 의 대상을 호출 가능 객체 f 로 설정하거나, f 가 널 함수 포인터, 널 멤버 함수 포인터, 또는 빈 std::move_only_function 인 경우 현재 대상을 파괴합니다. 이는 move_only_function ( std:: forward < F > ( f ) ) . swap ( * this ) ; 를 실행하는 것과 같습니다. 이 오버로드는 move_only_function F 에서의 생성자가 오버로드 해결에 참여하는 경우에만 오버로드 해결에 참여합니다. 선택된 생성자 호출이 잘못되었거나 정의되지 않은 동작을 가지는 경우 프로그램은 잘못되었거나 정의되지 않은 동작을 가집니다.

목차

매개변수

other - 다른 std::move_only_function 객체로 대상 이동
f - 새로운 대상을 초기화하기 위한 호출 가능 객체

반환값

* this

참고 사항

move 할당 연산자에 noexcept 를 요구하지 않는 것은 의도적인 것으로, 향후 allocator-aware move_only_function 을 위한 여지를 남기기 위함입니다.

move_only_function 는 해당 인수로부터 생성될 수 있는 경우 std:: in_place_type < Fn > 로부터 할당될 수 있습니다.

예제

참고 항목

새로운 대상을 할당함
( std::function<R(Args...)> 의 public 멤버 함수)