This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4395. write_env implementation-detail lambda should have explicit return type

Section: 33.9.12.3 [exec.write.env] Status: New Submitter: Robert A.H. Leahy Opened: 2025-09-29 Last modified: 2025-10-04

Priority: Not Prioritized

View all issues with New status.

Discussion:

In 33.9.12.3 [exec.write.env] the impls for std::execution::write_env has get-env specified as:

static constexpr auto get-env =
  [](auto, const auto& state, const auto& rcvr) noexcept {
    return see-below;
  };

This uses automatic return type deduction which means that the body of the lambda is actually instantiated in a SFINAE-unfriendly way when attempting to compute various properties of the lambda (invocability, return type, et cetera). This is undesirable and surprising as has been discovered in actual use/deployment (see: https://github.com/NVIDIA/stdexec/pull/1654).

The fix is to explicitly provide a return type for the lambda which computes the type of the body.

Note: This issue may indicate that the use of automatic return type deduction in the specification of sender algorithms more generally ought to be reconsidered/-examined.

Proposed resolution: