33 Execution control library [exec]

33.14 Execution scope utilities [exec.scope]

33.14.1 Execution scope concepts [exec.scope.concepts]

The scope_association concept defines the requirements on a type Assoc.
An object of type Assoc is engaged if and only if it owns an association with an async scope, referred to as its associated scope.
namespace std::execution { template<class Assoc> concept scope_association = movable<Assoc> && is_nothrow_move_constructible_v<Assoc> && is_nothrow_move_assignable_v<Assoc> && default_initializable<Assoc> && requires(const Assoc assoc) { { static_cast<bool>(assoc) } noexcept; { assoc.try_associate() } -> same_as<Assoc>; }; }
A type Assoc models scope_association only if:
  • a default constructed object of type Assoc is not engaged;
  • for an object assoc of type Assoc, static_cast<bool>(assoc) is true if and only if assoc is engaged;
  • no two distinct objects of type Assoc own the same assocation;
  • for an object assoc of type Assoc, destroying assoc releases the assocation owned by assoc, if any;
  • for an object assoc of type Assoc, after it is used as the source operand of a move constructor, the assoc is not engaged;
  • for distinct objects assoc1 and assoc2 of type Assoc, after evaluating assoc1 = std​::​move(assoc2), the association owned by assoc1, if any, is released and assoc2 is not engaged;
  • for an object assoc of type Assoc that is engaged, assoc.try_associate() either returns an object that is not engaged or acquires a new association with assoc's associated scope and returns an engaged object that owns that association;
  • for an object assoc of type Assoc that is not engaged, assoc.try_associate() returns an object that is not engaged.
The scope_token concept defines the requirements on a type Token that can be used to create associations between senders and an async scope.
Every object of type Token is associated with an async scope that is referred to as its associated scope.
Let test-sender and test-env be unspecified types such that sender_in<test-sender, test-env> is modeled.
namespace std::execution { template<class Token> concept scope_token = copyable<Token> && requires(const Token token) { { token.try_associate() } -> scope_association; { token.wrap(declval<test-sender>()) } -> sender_in<test-env>; }; }
A type Token models scope_token only if:
  • no exceptions are thrown from copy construction, move construction, copy assignment, or move assignment of objects of type Token;
  • for an object token of type Token, token.try_associate() either returns an object that is not engaged or acquires a new association with token's associated scope and returns an engaged object that owns that association; and
  • given an lvalue token of type (possibly const) Token, for all expressions sndr such that decltype((
    sndr))
    models sender:
    • token.wrap(sndr) is a valid expression,
    • decltype(token.wrap(sndr)) models sender, and
    • completion_signatures_of_t<decltype(token.wrap(sndr)), E> contains the same completion signatures as completion_signatures_of_t<decltype((sndr)), E> for all types E such that sender_in<decltype((sndr)), E> is modeled.