Function objects | |
| |
| |
| |
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++17*)(until C++17*)(until C++17*)(until C++17*) | | |
|
template<class F> function_ref( F* f)noexcept; | (1) | (since C++26) |
template<class F> function_ref( F&& f)noexcept; | (2) | (since C++26) |
| (3) | (since C++26) |
template<auto f,class U> function_ref(std::nontype_t<f>, U&& obj)noexcept; | (4) | (since C++26) |
template<auto f,class T> function_ref(std::nontype_t<f>,/*cv*/ T* obj)noexcept; | (5) | (since C++26) |
function_ref(const function_ref& other)=default; | (6) | (since C++26) |
| | |
Creates a newstd::function_ref
.
1) Initializes
bound-entity
with
f, and
thunk-ptr
with the address of a function
thunk
. The behavior is undefined if
f is a null pointer.
- This overload participates in overload resolution only if bothstd::is_function_v<F> and/*is-invocable-using*/<F> aretrue.
2) Initializes
bound-entity
with
std::addressof(f), and
thunk-ptr
with the address of a function
thunk
.
3) Initializes
bound-entity
with a pointer to an unspecified object or null pointer value, and
thunk-ptr
with the address of a function
thunk
.
- LetF bedecltype(f). This overload participates in overload resolution only if/*is-invocable-using*/<F> istrue.
- The program is ill-formed iff!= nullptr isfalse whenstd::is_pointer_v<F>||std::is_member_pointer_v<F> istrue.
4) Initializes
bound-entity
with
std::addressof(obj), and
thunk-ptr
with the address of a function
thunk
.
5) Initializes
bound-entity
with
obj, and
thunk-ptr
with the address of a function
thunk
. The behavior is undefined if
obj is a null pointer when
std::is_member_pointer_v<F> is
true.
- LetF bedecltype(f). This overload participates in overload resolution only if/*is-invocable-using*/<F,/*cv*/ T*> istrue.
- The program is ill-formed iff!= nullptr isfalse whenstd::is_pointer_v<F>||std::is_member_pointer_v<F> istrue.
6) Defaulted copy constructor copies thebound-entity
andthunk-ptr
ofother.
The address of a functionthunk
is used to initializethunk-ptr
such that a call tothunk
(bound-entity
, call-args
...) isexpression-equivalent to:
/*is-invocable-using*/<T...> istrue if and only if:
[edit]Parameters
other | - | anotherfunction_ref to copy from |
f | - | a function or aCallable object to wrap |
obj | - | an object or pointer to bound |
[edit]Example
| This section is incomplete Reason: no example |
[edit]See also
| constructs a newstd::move_only_function object (public member function ofstd::move_only_function )[edit] |