Namespaces
Variants

std::function_ref:: function_ref

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* )
template < class F >
function_ref ( F * f ) noexcept ;
(1) (C++26부터)
template < class F >
function_ref ( F && f ) noexcept ;
(2) (C++26부터)
template < auto f >
function_ref ( std:: nontype_t < f > ) noexcept ;
(3) (C++26부터)
template < auto f, class U >
function_ref ( std:: nontype_t < f > , U && obj ) noexcept ;
(4) (C++26부터)
template < auto f, class T >
function_ref ( std:: nontype_t < f > , /*cv*/ T * obj ) noexcept ;
(5) (C++26부터)
function_ref ( const function_ref & other ) = default ;
(6) (C++26부터)

새로운 std::function_ref 를 생성합니다.

1) bound-entity f 로 초기화하고, thunk-ptr thunk 함수의 주소로 초기화합니다. f 가 null 포인터인 경우의 동작은 정의되지 않습니다.
  • 이 오버로드는 std:: is_function_v < F > /*is-invocable-using*/ < F > 가 모두 true 인 경우에만 오버로드 해결에 참여합니다.
2) bound-entity std:: addressof ( f ) 로 초기화하고, thunk-ptr 를 함수 thunk 의 주소로 초기화합니다.
3) bound-entity 를 지정되지 않은 객체에 대한 포인터 또는 null 포인터 값으로 초기화하고, thunk-ptr 을 함수 thunk 의 주소로 초기화합니다.
  • F decltype ( f ) 로 둡니다. 이 오버로드는 /*is-invocable-using*/ < F > true 인 경우에만 오버로드 해결에 참여합니다.
  • std:: is_pointer_v < F > || std:: is_member_pointer_v < F > true 일 때 f ! = nullptr false 이면 프로그램의 형식이 올바르지 않습니다.
4) bound-entity std:: addressof ( obj ) 로 초기화하고, thunk-ptr 를 함수 thunk 의 주소로 초기화합니다.
5) bound-entity obj 로 초기화하고, thunk-ptr 를 함수 thunk 의 주소로 초기화합니다. std:: is_member_pointer_v < F > true 일 때 obj 가 null 포인터인 경우 동작은 정의되지 않습니다.
  • F decltype ( f ) 라고 합니다. 이 오버로드는 /*is-invocable-using*/ < F, /*cv*/ T * > true 인 경우에만 오버로드 해결에 참여합니다.
  • std:: is_pointer_v < F > || std:: is_member_pointer_v < F > true 일 때 f ! = nullptr false 이면 프로그램의 형식이 올바르지 않습니다.
6) 디폴트 복사 생성자는 bound-entity thunk-ptr other 의 것으로 복사합니다.

함수의 주소 thunk thunk-ptr 를 초기화하는 데 사용되며, 이때 thunk ( bound-entity , call-args ... ) 호출은 다음 표현식과 표현식 동등 합니다:

오버로드 표현식 동등성
( 1,3 ) std:: invoke_r < R > ( f, call-args ... )
( 2 ) std:: invoke_r < R > ( static_cast < cv T & > ( f ) , call-args ... )
( 4 ) std:: invoke_r < R > ( f, static_cast < cv T & > ( obj ) , call-args ... )
( 5 ) std:: invoke_r < R > ( f, obj, call-args ... )

/*is-invocable-using*/ < T... > 는 다음 조건에서만 true 입니다:

매개변수

other - 복사할 다른 function_ref
f - 래핑할 함수 또는 Callable 객체
obj - 바인딩할 객체 또는 포인터

예제

참고 항목

새로운 std::move_only_function 객체를 생성함
( std::move_only_function 의 public 멤버 함수)