std::function_ref:: function_ref
|
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
를 생성합니다.
bound-entity
를
f
로 초기화하고,
thunk-ptr
를
thunk
함수의 주소로 초기화합니다.
f
가 null 포인터인 경우의 동작은 정의되지 않습니다.
- 이 오버로드는 std:: is_function_v < F > 와 /*is-invocable-using*/ < F > 가 모두 true 인 경우에만 오버로드 해결에 참여합니다.
bound-entity
를
std::
addressof
(
f
)
로 초기화하고,
thunk-ptr
를 함수
thunk
의 주소로 초기화합니다.
-
T
를
std::
remove_reference_t
<
F
>
로 정의합니다. 이 오버로드는 다음 조건을 만족할 때만 오버로드 해결에 참여합니다:
-
std::
remove_cvref_t
<
F
>
가
function_ref와 동일한 타입이 아니고, - std:: is_member_pointer_v < T > 가 false 이고,
- /*is-invocable-using*/ < /*cv*/ T & > 가 true 인 경우.
-
std::
remove_cvref_t
<
F
>
가
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 이면 프로그램의 형식이 올바르지 않습니다.
bound-entity
를
std::
addressof
(
obj
)
로 초기화하고,
thunk-ptr
를 함수
thunk
의 주소로 초기화합니다.
-
T
를
std::
remove_reference_t
<
U
>
로,
F
를
decltype
(
f
)
로 설정합니다. 이 오버로드는 다음 조건을 만족할 때만 오버로드 해결에 참여합니다:
- std:: is_rvalue_reference_v < U && > 가 false 인 경우, 그리고
- /*is-invocable-using*/ < F, /*cv*/ T & > 가 true 인 경우.
- std:: is_pointer_v < F > || std:: is_member_pointer_v < F > 가 true 일 때 f ! = nullptr 가 false 이면 프로그램의 형식이 올바르지 않습니다.
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 이면 프로그램의 형식이 올바르지 않습니다.
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 입니다:
- std:: is_nothrow_invocable_r_v < R, T..., Args... > 가 true 인 경우, 또는
- std:: is_invocable_r_v < R, T..., Args... > 가 true 인 경우
매개변수
| other | - |
복사할 다른
function_ref
|
| f | - | 래핑할 함수 또는 Callable 객체 |
| obj | - | 바인딩할 객체 또는 포인터 |
예제
|
이 섹션은 불완전합니다
이유: 예시가 없음 |
참고 항목
새로운
std::move_only_function
객체를 생성함
(
std::move_only_function
의 public 멤버 함수)
|