std::experimental::scope_success<EF>::scope_success
From cppreference.com
< cpp | experimental | scope success
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Experimental
Filesystem library (filesystem TS)
Library fundamentals (library fundamentals TS)
Library fundamentals 2 (library fundamentals TS v2)
Library fundamentals 3 (library fundamentals TS v3)
Extensions for parallelism (parallelism TS)
Extensions for parallelism 2 (parallelism TS v2)
Extensions for concurrency (concurrency TS)
Extensions for concurrency 2 (concurrency TS v2)
Concepts (concepts TS)
Ranges (ranges TS)
Reflection (reflection TS)
Mathematical special functions (special functions TR)
std::experimental::scope_success
Member functions
scope_success::scope_success
Modifiers
template< class Fn >
explicit scope_success( Fn&& fn ) noexcept(/*see below*/);
(1)
(library fundamentals TS v3)
explicit scope_success( Fn&& fn ) noexcept(/*see below*/);
scope_success( scope_success&& other ) noexcept(/*see below*/);
(2)
(library fundamentals TS v3)
scope_success( const scope_success& ) = delete;
(3)
(library fundamentals TS v3)
Creates a scope_success
from a function, a function object or another scope_success
.
1) Initializes the exit function with a function or function object, and initializes the counter of uncaught exceptions as if with std::uncaught_exceptions (). The constructed
scope_success
is active. If
Fn
is not an lvalue reference type and std::is_nothrow_constructible_v <EF, Fn> is true, the stored EF
is initialized with std::forward <Fn>(fn); otherwise it is initialized with fn. This overload participates in overload resolution only if std::is_same_v <std::remove_cvref_t <Fn>, scope_success> is false and std::is_constructible_v <EF, Fn> is true.
The program is ill-formed if function call expression fn() is ill-formed.
The behavior is undefined if calling fn() results in undefined behavior, even if fn has not been called.
2) Move constructor. Initializes the stored
EF
with the one in other, and initializes the counter of uncaught exceptions with the one in other. The constructed scope_success
is active if and only if other is active before the construction. If std::is_nothrow_move_constructible_v <EF> is true, initializes stored
EF
(denoted by exitfun
) with std::forward <EF>(other.exitfun), otherwise initializes it with other.exitfun. After successful move construction, other.release() is called and other becomes inactive.
This overload participates in overload resolution only if std::is_nothrow_move_constructible_v <EF> is true or std::is_copy_constructible_v <EF> is true.
The behavior is undefined if
- std::is_nothrow_move_constructible_v <EF> is true and
EF
does not meet the requirements of MoveConstructible, or - std::is_nothrow_move_constructible_v <EF> is false and
EF
does not meet the requirements of CopyConstructible.
Contents
[edit] Parameters
fn
-
function or function object used for initializing the stored
EF
other
-
scope_success
to move from
[edit] Exceptions
Any exception thrown during the initialization of the stored EF
.
1)
noexcept specification:
noexcept(std::is_nothrow_constructible_v <EF, Fn> ||
std::is_nothrow_constructible_v <EF, Fn&>)
std::is_nothrow_constructible_v <EF, Fn&>)
2)
noexcept specification:
noexcept(std::is_nothrow_move_constructible_v <EF> ||
std::is_nothrow_copy_constructible_v <EF>)
std::is_nothrow_copy_constructible_v <EF>)
[edit] Example
This section is incomplete
Reason: no example
Reason: no example