std::experi...hared_future(3)

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

std::experi...hared_future(3) πŸ’…

Bestie, this is the manual page for std::experimental::shared_future::shared_future, pulled from the C++ Standard Libary (yes, the header spells it "Libary" β€” iconic typo, no notes 😭). It's the constructor page for the experimental shared_future, and we're about to go through every overload like a group-chat recap. 🫢

🌸 NAME 🌸

std::experimental::shared_future::shared_future β€” literally the constructors for std::experimental::shared_future, same name twice because that's how constructors roll. Periodt. πŸ’…

✨ SYNOPSIS ✨

shared_future() noexcept;
(1)
shared_future( std::experimental::shared_future<T>&& f ) noexcept;
(2)
shared_future( const std::experimental::shared_future<T>& f );
(3)
shared_future(
std::experimental::future<std::experimental::shared_future<T>>   (4)
&& other ) noexcept;
shared_future( std::experimental::future<T>&& f ) noexcept;
(5)

Here's the tea on each numbered constructor, no skipping:

  1. Default constructor. Constructs an empty shared_future object that does not refer to a shared state. It's giving "empty and unbothered." ✨
  2. Constructs a shared_future object, transferring the shared state held by f, if any. After construction, f.valid() is false. So f hands over the state and is left invalid β€” no cap. 🫢
  3. Constructs a shared future that refers to the same shared state as f, if any. Same state, shared vibes. πŸ’–
  4. Unwrapping constructor. Constructs a shared_future object from the shared state referred to by other, if any. If other.valid() == false prior to this call, the constructed shared_future object is empty. Otherwise, the resulting shared_future object becomes ready when one of these happens:
    • other and other.get() are both ready. The value or exception from other.get() is stored in the shared state associated with the resulting shared_future object.
    • other is ready, but other.get() is invalid. An exception of type std::future_error with an error condition of std::future_errc::broken_promise is stored in the shared state associated with the resulting shared_future object. After this constructor returns, valid() is equal to the value of other.valid() prior to this call, and other.valid() == false. That's the whole unwrapping saga, bestie. πŸ’€
  5. Constructs a shared_future object, transferring the shared state held by f, if any. After construction, f.valid() is false. Basically overload 2's energy, but with std::experimental::future<T>&& f. πŸ”₯

πŸŽ€ PARAMETERS πŸŽ€

  • f β€” another future object to initialize with.
  • other β€” a std::experimental::future object to unwrap.

πŸ¦‹ EXAMPLE πŸ¦‹

Ok so this section is incomplete, and the reason is literally "no example":

This section is incomplete Reason: no example

No example bestie, not even a little one. 😭

πŸ’€ DEFECT REPORTS πŸ’€

The following behavior-changing defect reports were applied retroactively to previously published C++ standards. Here's the one on this page, kept cute but factual:

  • DR: LWG 2697 β€” Applied to: Concurrency TS. Behavior as published: behavior of unwrapping constructor is unclear with an invalid future. Correct behavior: constructs an empty future. πŸ’…

πŸ”₯ SEE ALSO πŸ”₯

  • constructor β€” constructs the future object (public member function of std::shared_future<T>).

🌈 CATEGORY 🌈

  • Todo no example

Signed with sparkles by http://cppreference.com, version/date 2024.06.10, for page std::experi...hared_future(3) πŸ’–βœ¨

πŸ“¦ where this page comes from