Skip to content

receiver/sender concepts require get_env but this has a fallback that accepts any type #321

Open
@lewissbaker

Description

@lewissbaker

The receiver and sender concepts both require that the type supports calling get_env(obj) on an object of that type. e.g.

// [exec.recv.concepts]
template<class Rcvr>
    concept receiver =
      derived_from<typename remove_cvref_t<Rcvr>::receiver_concept, receiver_t> &&
      requires(const remove_cvref_t<Rcvr>& rcvr) {
        { get_env(rcvr) } -> queryable;
      } &&
      move_constructible<remove_cvref_t<Rcvr>> &&       // rvalues are movable, and
      constructible_from<remove_cvref_t<Rcvr>, Rcvr>;   // lvalues are copyable

However, the get_env() CPO is defined to have a fall-back implementation that gets invoked if the object doesn't have a .get_env() member function, which just returns an empty environment.

[exec.get.env] says:

For a sub-expression o, execution::get_env(0) is expression-equivalent to:

  • MANDATE-NOTHROW(as_const(o).get_env()) if that expression is well-formed.
    Mandates: The type of the expression above satisfies queryable ([exec.queryable]])
  • Otherwise, env<>{}.

This means that the constraint that you can call get_env is not going to be very selective as it will work with any type that hasn't defined a non-compliant get_env member-function.
Do we need to have the constraint that get_env is callable here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions