std::experi...cope_success(3)
π std::experi...cope_success(3) π
okay so bestie, this page comes from the C++ Standard Libary manual (yes, the header spells it like that π), and it's the whole constructor saga for std::experimental::scope_success::scope_success. no cap, it's giving very niche RAII group-chat energy. π
π NAME π
std::experimental::scope_success::scope_success β std::experimental::scope_success::scope_success
πΈ Synopsis πΈ
template< class Fn >
explicit scope_success( Fn&& fn ) noexcept(/*see (1) (library
fundamentals TS v3)
below*/);
scope_success( scope_success&& other ) (2) (library
fundamentals TS v3)
noexcept(/*see below*/);
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. slay. β¨
- Initializes the exit function with a function or function object, and initializes the counter of uncaught exceptions as if with
std::uncaught_exceptions(). The constructedscope_successis 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 callingfn()results in undefined behavior, even iffnhas not been called. that's the dramatic part, bestie. π
- Move constructor. Initializes the stored
EFwith the one inother, and initializes the counter of uncaught exceptions with the one inother. The constructedscope_successis active if and only ifotheris 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 andEFdoes not meet the requirements ofMoveConstructible, or -std::is_nothrow_move_constructible_v<EF>is false andEFdoes not meet the requirements ofCopyConstructible.
scope_successis notCopyConstructible. periodt. π«
πΈ Parameters πΈ
fnβ function or function object used for initializing the storedEF.otherβscope_successto move from.
π Exceptions π
Any exception thrown during the initialization of the stored EF. π
noexceptspecification:
noexcept(std::is_nothrow_constructible_v<EF, Fn> ||
std::is_nothrow_constructible_v<EF, Fn&>)
noexceptspecification:
noexcept(std::is_nothrow_move_constructible_v<EF> ||
std::is_nothrow_copy_constructible_v<EF>)
π Example π
This section is incomplete. Reason: no example. not me showing up with zero example energy ππ
π See also π
The See also block is a little chaotic in the original, but every bit is here:
uncaught_exceptionuncaught_exceptionsβ checks if exception handling is currently in progress(removed in C++20)(function)(C++17)β the tags the page has hanging around herereleaseβ makes thescope_successinactive(public member function)
π Categories: π
- conditionally
noexcept - Todo no example
that's the whole constructor page, bestie. source/version/date sign-off: http://cppreference.com, 2024.06.10, and the header title std::experi...cope_success(3). mwah, go forth and RAII responsibly π«Άπ
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms