std::move_only_function::move_only_function
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
旧绑定器与适配器 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
成员函数 | ||||
move_only_function::move_only_function
(C++23)
|
||||
(C++23)
|
||||
(C++23)
|
||||
(C++23)
|
||||
非成员函数 | ||||
(C++23)
|
||||
(C++23)
|
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>, |
(7) | (C++23 起) |
创建新的 std::move_only_function
。
std::move_only_function
。other
的目标的 std::move_only_function
。移动构造后 other
在拥有未指定值的合法状态。VT
为 std::decay_t<F> 。若
f
为空函数指针、空成员指针或空 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 则程序非良构。
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
不是同一类型则程序非良构。
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 但不满足可移动构造 (MoveConstructible)
要求则行为未定义。
常量 /*is-callable-from*/<VT> 以如下方式取决于
std::move_only_function
的模板形参中的 cv、 ref 及
noex :
cv ref noexcept(noex) | /*is-callable-from*/<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 |
异常
示例
本节未完成 原因:暂无示例 |
参阅
构造新的 std::function
实例 ( std::function<R(Args...)>
的公开成员函数) |