move_only_function() noexcept; | (1) | (since C++23) |
move_only_function( std::nullptr_t ) noexcept; | (2) | (since C++23) |
move_only_function( move_only_function&& other ) noexcept; | (3) | (since C++23) |
move_only_function( const move_only_function& ) = delete; | (4) | (since C++23) |
template< class F > move_only_function( F&& f ); | (5) | (since C++23) |
template< class T, class... CArgs > explicit move_only_function( std::in_place_type_t<T>, CArgs&&... args ); | (6) | (since 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) | (since C++23) |
Creates a new std::move_only_function
.
nullptr
construct an empty std::move_only_function
.std::move_only_function
whose target is that of other
. other
is in a valid but unspecified state after move construction.VT
be std::decay_t<F>
. If f
is a null function pointer, a null pointer to member value, or an empty std::move_only_function
(may be any specialization), then constructs an empty std::move_only_function
. Otherwise, constructs a std::move_only_function
whose target is of type VT
and direct-non-list-initialized with std::forward<F>(f)
. VT
is neither same as move_only_function
nor a specialization of std::in_place_type_t
, and /*is-callable-from*/<VT>
(see below) is true
. std::is_constructible_v<VT, F>
is not true
.VT
be std::decay_t<T>
. Constructs a std::move_only_function
whose target is of type VT
and direct-non-list-initialized with std::forward<CArgs>(args)...
. std::is_constructible_v<VT, CArgs...>
and /*is-callable-from*/<VT>
(see below) are true
. VT
is not the same type as T
.VT
be std::decay_t<T>
. Constructs a std::move_only_function
whose target is of type VT
and direct-non-list-initialized with il, std::forward<CArgs>(args)...
. std::is_constructible_v<VT, std::initializer_list<U>&, CArgs...>
and /*is-callable-from*/<VT>
(see below) are true
. VT
is not the same type as T
.For constructors (5-7), the behavior is undefined if VT
does not satisfy the Destructible requirements, or std::is_move_constructible_v<VT>
is true
but VT
does not satisfy the MoveConstructible requirements.
The constant /*is-callable-from*/<VT>
is dependent on cv, ref, and noex in the template parameter of std::move_only_function
as below:
cv ref noexcept( noex) | /*is-callable-from*/<VT> |
---|---|
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...> |
&& 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 | - | another std::move_only_function to move from |
f | - | a function or a Callable object to wrap |
args | - | arguments to construct the target object |
il | - | std::initializer_list to construct the target object |
std::bad_alloc
on allocation failure or propagate the exception thrown by the initialization of the target. No exception is thrown if VT
is a function pointer type or a specialization of std::reference_wrapper
. constructs a new std::function instance (public member function of std::function<R(Args...)> ) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/utility/functional/move_only_function/move_only_function