Skip to content

restore the enable_sender boolean variable template #306

Open
@ericniebler

Description

@ericniebler

as described in issue #305, enable_sender variable template was an important way to opt in to sender-ness, particularly for types that are awaitable, but only in certain contexts. this functionality was lost during wording review(?) when enable_sender got turned into an exposition-only enable-sender concept.

we should roll back that change.

Proposed resolution

Change [exec.snd.concepts] para 1 as follows:

  template<class Sndr>
    concept is-sender =                                         // exposition only
      derived_from<typename Sndr::sender_concept, sender_t>;

  template<class Sndr>
    concept enable-sender =                                     // exposition only
      is-sender<Sndr> ||
      is-awaitable<Sndr, env-promise<empty_env>>;               // [exec.awaitable]

+ template<class Sndr>
+   inline constexpr bool enable_sender = enable-sender<Sndr>;

  template<class Sndr>
    concept sender =
-     bool(enable-sender<remove_cvref_t<Sndr>>) &&
+     enable_sender<remove_cvref_t<Sndr>> &&
      requires (const remove_cvref_t<Sndr>& sndr) {
        { get_env(sndr) } -> queryable;
      } &&
      move_constructible<remove_cvref_t<Sndr>> &&
      constructible_from<remove_cvref_t<Sndr>, Sndr>;

we also need the standardese permitting users to specialize enable_sender. after [exec.snd.concepts] para 2, add a new paragraph as follows:

  1. Remarks: Pursuant to [namespace.std], users may specialize enable_sender to true for cv-unqualified program-defined types that model sender, and false for types that do not. Such specializations shall be usable in constant expressions ([expr.const]) and have type const bool.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0bugSomething isn't workingpending-wg21A paper or an LWG issue exits

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions