std::experimental::scope_success<EF>:: scope_success
From cppreference.net
<
cpp
|
experimental
|
scope success
|
template
<
class
Fn
>
explicit scope_success ( Fn && fn ) noexcept ( /*see below*/ ) ; |
(1) | (基础库TS v3) |
|
scope_success
(
scope_success
&&
other
)
noexcept
(
/*see below*/
)
;
|
(2) | (基础库TS v3) |
|
scope_success
(
const
scope_success
&
)
=
delete
;
|
(3) | (基础库TS v3) |
从函数、函数对象或其他
scope_success
创建
scope_success
对象。
若
Fn
不是左值引用类型且
std::
is_nothrow_constructible_v
<
EF, Fn
>
为
true
,则存储的
EF
以
std::
forward
<
Fn
>
(
fn
)
初始化;否则以
fn
初始化。
此重载仅当
std::
is_same_v
<
std::
remove_cvref_t
<
Fn
>
, scope_success
>
为
false
且
std::
is_constructible_v
<
EF, Fn
>
为
true
时参与重载决议。
如果函数调用表达式
fn
(
(
)
的格式不正确,则程序是非良构的。
若调用
fn
(
)
会导致未定义行为,则当前行为未定义,即使
fn
尚未被调用。
2)
移动构造函数。使用
other
中的存储
EF
进行初始化,并使用
other
中的未捕获异常计数器进行初始化。构造的
scope_success
对象处于活动状态当且仅当构造前
other
处于活动状态。
若
std::
is_nothrow_move_constructible_v
<
EF
>
为
true
,则使用
std::
forward
<
EF
>
(
other.
exitfun
)
初始化存储的
EF
(记为
exitfun
),否则使用
other.
exitfun
进行初始化。
成功进行移动构造后,将调用
other.
release
(
)
且
other
变为非活动状态。
此重载仅当
std::
is_nothrow_move_constructible_v
<
EF
>
为
true
或
std::
is_copy_constructible_v
<
EF
>
为
true
时参与重载决议。
若满足以下任一条件,则行为未定义:
-
std::
is_nothrow_move_constructible_v
<
EF
>
为
true
且
EF不满足 MoveConstructible 要求,或 -
std::
is_nothrow_move_constructible_v
<
EF
>
为
false
且
EF不满足 CopyConstructible 要求。
目录 |
参数
| fn | - |
用于初始化存储的
EF
的函数或函数对象
|
| other | - |
要从中移动的
scope_success
对象
|
异常
在存储的
EF
初始化期间抛出的任何异常。
1)
noexcept
规范:
noexcept
(
std::
is_nothrow_constructible_v
<
EF, Fn
>
||
std:: is_nothrow_constructible_v < EF, Fn & > )
std:: is_nothrow_constructible_v < EF, Fn & > )
2)
noexcept
规范:
noexcept
(
std::
is_nothrow_move_constructible_v
<
EF
>
||
std:: is_nothrow_copy_constructible_v < EF > )
std:: is_nothrow_copy_constructible_v < EF > )
示例
|
本节内容不完整
原因:缺少示例 |
参见
|
(
C++17中弃用*
)
(C++17)
|
检查异常处理是否正在进行中
(函数) |
使
scope_success
变为非活动状态
(公开成员函数) |