Namespaces
Variants

std::experimental::scope_success<EF>:: scope_success

From cppreference.net

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 对象。

1) 使用函数或函数对象初始化退出函数,并如同通过 std:: uncaught_exceptions ( ) 般初始化未捕获异常计数器。构造的 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 时参与重载决议。
若满足以下任一条件,则行为未定义:
3) scope_success 不满足 CopyConstructible 要求。

目录

参数

fn - 用于初始化存储的 EF 的函数或函数对象
other - 要从中移动的 scope_success 对象

异常

在存储的 EF 初始化期间抛出的任何异常。

示例

参见

( C++17中弃用* ) (C++17)
检查异常处理是否正在进行中
(函数)
使 scope_success 变为非活动状态
(公开成员函数)