Namespaces
Variants

std::move_only_function:: move_only_function

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 ( ) noexcept ;
(1) (C++23부터)
move_only_function ( std:: nullptr_t ) noexcept ;
(2) (C++23부터)
move_only_function ( move_only_function && other ) noexcept ;
(3) (C++23부터)
move_only_function ( const move_only_function & ) = delete ;
(4) (C++23부터)
template < class F >
move_only_function ( F && f ) ;
(5) (C++23부터)
template < class T, class ... CArgs >
explicit move_only_function ( std:: in_place_type_t < T > , CArgs && ... args ) ;
(6) (C++23부터)
template < class T, class U, class ... CArgs >

explicit move_only_function ( std:: in_place_type_t < T > ,

std:: initializer_list < U > il, CArgs && ... args ) ;
(7) (C++23부터)

새로운 std::move_only_function 을 생성합니다.

1,2) 기본 생성자와 nullptr 를 받는 생성자는 빈 std::move_only_function 을 생성합니다.
3) 이동 생성자는 std::move_only_function 의 대상이 other 인 대상을 가지는 객체를 생성합니다. other 는 이동 생성 후 유효하지만 지정되지 않은 상태가 됩니다.
4) 복사 생성자가 삭제되었습니다. std::move_only_function CopyConstructible 요구 사항을 충족하지 않습니다.
5) VT std:: decay_t < F > 로 정의한다. 만약 f 가 null 함수 포인터, null 멤버 포인터 값, 또는 빈 std::move_only_function (다른 특수화일 수 있음)인 경우, 빈 std::move_only_function 을 생성한다. 그렇지 않으면, 대상이 VT 타입이며 std:: forward < F > ( f ) 로 직접-비목록-초기화된 std::move_only_function 을 생성한다.
  • 이 오버로드는 VT move_only_function 과 동일하지 않고 std::in_place_type_t 의 특수화도 아니며, /*is-callable-from*/ < VT > (아래 참조)가 true 인 경우에만 오버로드 해결에 참여한다.
  • std:: is_constructible_v < VT, F > true 가 아닌 경우 프로그램은 ill-formed이다.
6) VT std:: decay_t < T > 로 정의합니다. 대상이 VT 타입이며 std:: forward < CArgs > ( args ) ... 로 직접-비목록-초기화된 std::move_only_function 을 생성합니다.
  • 이 오버로드는 std:: is_constructible_v < VT, CArgs... > /*is-callable-from*/ < VT > (아래 참조) 모두가 true 인 경우에만 오버로드 해결에 참여합니다.
  • VT T 와 동일한 타입이 아닌 경우 프로그램의 형식이 올바르지 않습니다.
7) VT std:: decay_t < T > 로 정의합니다. 대상의 타입이 VT 이고 il, std::forward<CArgs>(args)... 로 직접-비목록-초기화된 std::move_only_function 을 생성합니다.
  • 이 오버로드는 std:: is_constructible_v < VT, std:: initializer_list < U > & , CArgs... > /*is-callable-from*/ < VT > (아래 참조) 모두가 true 인 경우에만 오버로드 해결에 참여합니다.
  • VT T 와 동일한 타입이 아닌 경우 프로그램의 형식이 올바르지 않습니다.

생성자 (5-7) 의 경우, VT Destructible 요구 사항을 만족하지 않거나, std:: is_move_constructible_v < VT > true 이지만 VT MoveConstructible 요구 사항을 만족하지 않는 경우 동작은 정의되지 않습니다.

상수 /*is-callable-from*/ < VT > std::move_only_function 의 템플릿 매개변수에 있는 cv , ref , 그리고 noex 에 따라 아래와 같이 의존적입니다:

cv ref noexcept ( noex ) /*호출-가능-여부*/ < VT >
noexcept ( false ) std:: is_invocable_r_v < R, VT, Args... > &&

std:: is_invocable_r_v < R, VT & , Args... >

noexcept ( true ) std:: is_nothrow_invocable_r_v < R, VT, Args... > &&

std:: is_nothrow_invocable_r_v < R, VT & , Args... >

const noexcept ( false ) std:: is_invocable_r_v < R, const VT, Args... > &&

std:: is_invocable_r_v < R, const VT & , Args... >

const noexcept ( true ) std:: is_nothrow_invocable_r_v < R, const VT, Args... > &&

std:: is_nothrow_invocable_r_v < R, const VT & , Args... >

& noexcept ( false ) std:: is_invocable_r_v < R, VT & , Args... >
& noexcept ( true ) std:: is_nothrow_invocable_r_v < R, VT & , Args... >
const & noexcept ( false ) std:: is_invocable_r_v < R, const VT & , Args... >
const & noexcept ( true ) std:: is_nothrow_invocable_r_v < R, const VT & , Args... >
&& noexcept ( false ) std:: is_invocable_r_v < R, VT, Args... >
&& noexcept ( true ) std:: is_nothrow_invocable_r_v < R, VT, Args... >
const && noexcept ( false ) std:: is_invocable_r_v < R, const VT, Args... >
const && noexcept ( true ) std:: is_nothrow_invocable_r_v < R, const VT, Args... >

목차

매개변수

other - 이동할 다른 std::move_only_function
f - 래핑할 함수 또는 Callable 객체
args - 대상 객체를 생성하기 위한 인수들
il - std::initializer_list 대상 객체를 생성하기 위한 초기화자 목록

예외

5-7) 할당 실패 시 std::bad_alloc 을 던지거나 대상 초기화에서 발생한 예외를 전파할 수 있습니다. VT 가 함수 포인터 타입이거나 std::reference_wrapper 의 특수화인 경우에는 예외가 발생하지 않습니다.

예제

참고 항목

새로운 std::function 인스턴스를 생성합니다
( std::function<R(Args...)> 의 public 멤버 함수)
새로운 std::copyable_function 객체를 생성합니다
( std::copyable_function 의 public 멤버 함수)