std::move_only_function:: move_only_function
|
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
。
std::move_only_function
,其目标对象来自
other
。移动构造后
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::move_only_function
对象,该目标通过
std::
forward
<
CArgs
>
(
args
)
...
直接非列表初始化。
- 仅当 std:: is_constructible_v < VT, CArgs... > 与 /*is-callable-from*/ < VT > (见下文)均为 true 时,此重载才参与重载决议。
-
若
VT与T类型不同,则程序非良构。
VT
为
std::
decay_t
<
T
>
。构造一个目标类型为
VT
的
std::move_only_function
,该目标通过
il,
std::
forward
<
CArgs
>
(
args
)
...
进行直接非列表初始化。
- 仅当 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
但
VT
不满足
MoveConstructible
要求,则行为未定义。
常量
/*is-callable-from*/
<
VT
>
依赖于
std::move_only_function
模板参数中的
cv
、
ref
和
noex
,具体如下:
| cv ref noexcept ( noex ) | /*可从以下调用*/ < 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 | - | 要包装的函数或 可调用 对象 |
| args | - | 用于构造目标对象的参数 |
| il | - | 用于构造目标对象的 std::initializer_list 初始化列表 |
异常
示例
|
本节内容不完整
原因:缺少示例 |
参见
构造新的
std::function
实例
(
std::function<R(Args...)>
的公开成员函数)
|
|
构造新的
std::copyable_function
对象
(
std::copyable_function
的公开成员函数)
|