std::stop_s...:stop_source(3)

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

πŸ’– NAME πŸ’–

std::stop_source::stop_source β€” okay bestie, this is the constructor crew for std::stop_source, and the name is literally std::stop_source::stop_source again (it's giving β€œmy own name is my brand” πŸ’…). We're in the C++ Standard Libary manual β€” yes, spelled exactly like that in the header, I don't make the rules πŸŽ€ β€” on page std::stop_s...:stop_source(3), so that manual name + page title is folded in near the top like a little ribbon ✨.


✨ Synopsis ✨

okay so this is the constructor set, and every single one is since C++20 🌈. They all construct a new std::stop_source object. The signatures, copied exactly and looking all official:

          stop_source();                                           (1) (since
       C++20)
          explicit stop_source( std::nostopstate_t nss ) noexcept; (2) (since
       C++20)
          stop_source( const stop_source& other ) noexcept;        (3) (since
       C++20)
          stop_source( stop_source&& other ) noexcept;             (4) (since
       C++20)

Now the numbered tea β˜•:

  1. Constructs a stop_source with new stop-state. Fresh stop-state, new main character energy πŸ‘‘.
  2. Constructs an empty stop_source with no associated stop-state. Literally empty, no stop-state attached, okay? 🫢
  3. Copy constructor. Constructs a stop_source whose associated stop-state is the same as that of other. Shared stop-state, matching vibes πŸ’ž.
  4. Move constructor. Constructs a stop_source whose associated stop-state is the same as that of other; other is left empty. So other hands over its stop-state and then is left empty β€” iconic handoff πŸ’«.

πŸŽ€ Parameters πŸŽ€

  • nss β€” an std::nostopstate_t placeholder object to construct an empty stop_source. It's the β€œplease make this empty” token, periodt.
  • other β€” another stop_source object to construct this stop_source object with. Basically the source material, bestie πŸ¦‹.

πŸ¦‹ Postconditions πŸ¦‹

After construction, here's the vibe check:

  1. stop_possible() is true and stop_requested() is false.
  2. stop_possible() and stop_requested() are both false.
  3. *this and other share the same associated stop-state and compare equal.
  4. *this has other's previously associated stop-state, and other.stop_possible() is false.

πŸ’€ Exceptions πŸ’€

For constructor (1), if memory could not be allocated for the stop-state, the listed exception is std::bad_alloc. That's the one in the manual, bestie β€” no extra lore from me, just the facts πŸ’œ.


mwah πŸ’‹ that's the whole page. Footer source/version: http://cppreference.com; date: 2024.06.10; page: std::stop_s...:stop_source(3). Bye bestie, go construct responsibly πŸŽ€βœ¨

πŸ“¦ where this page comes from