3757. What's the effect of std::forward_like<void>(x)?

Section: 22.2.4 [forward] Status: C++23 Submitter: Jiang An Opened: 2022-08-24 Last modified: 2023-11-22

Priority: Not Prioritized

View all other issues in [forward].

View all issues with C++23 status.

Discussion:

Currently the return type of std::forward_like is specified by the following bullet:

— Let V be

OVERRIDE_REF(T&&, COPY_CONST(remove_reference_t<T>, remove_reference_t<U>))

where T&& is not always valid, e.g. it's invalid when T is void.

A strait forward reading may suggest that there is a hard error when T is not referenceable (which is currently implemented in MSVC STL), but this seems not clarified. It is unclear to me whether the intent is that hard error, substitution failure, or no error is caused when T&& is invalid.

[2022-09-23; Reflector poll]

Set status to Tentatively Ready after seven votes in favour during reflector poll.

[2022-11-12 Approved at November 2022 meeting in Kona. Status changed: Voting → WP.]

Proposed resolution:

This wording is relative to N4917.

  1. Modify 22.2.4 [forward] as indicated:

    template<class T, class U>
      [[nodiscard]] constexpr auto forward_like(U&& x) noexcept -> see below;
    

    Mandates: T is a referenceable type (3.44 [defns.referenceable]).

    […]