std::experi...cope_success(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– 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. ✨

  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. that's the dramatic part, bestie. πŸ’€
  1. 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.
  1. scope_success is not CopyConstructible. periodt. 🚫

🌸 Parameters 🌸

  • fn β€” function or function object used for initializing the stored EF.
  • other β€” scope_success to move from.

πŸ’€ 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&>)
  1. noexcept specification:
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_exception
  • uncaught_exceptions β€” checks if exception handling is currently in progress
  • (removed in C++20) (function) (C++17) β€” the tags the page has hanging around here
  • release β€” makes the scope_success inactive (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