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

2390. [fund.ts] Invocation types and rvalues

Section: 3.3.2 [fund.ts::meta.trans.other] Status: TS Submitter: Michael Spertus Opened: 2014-05-26 Last modified: 2017-07-30

Priority: Not Prioritized

View all other issues in [fund.ts::meta.trans.other].

View all issues with TS status.

Discussion:

Addresses: fund.ts

invocation_type falls short of its stated goals in the following case. Using the notation of Invocation type traits, consider

void f(int const& i);
more_perfect_forwarding_async(f, int(7)); // Oops. Dangling reference because rvalue gone when async runs

This was always the advertised intent of the proposal, but while the language reflects this for the first parameter in the case of a member pointer, it failed to include corresponding language for other parameters.

[2014-06-18, Rapperswil]

Mike Spertus, Richard Smith, Jonathan Wakely, and Jeffrey Yasskin suggest improved wording.

Previous resolution [SUPERSEDED]:

This wording is relative to N3908.

  1. Change Table 3, [meta.trans.other] in the Library TS as indicated:

    Table 3 — Other type transformations
    Template Condition Comments
    template <class Fn, class... ArgTypes>
    struct invocation_type<Fn(ArgTypes...)>;
    Fn and all types in the parameter pack ArgTypes
    shall be complete types, (possibly cv-qualified) void,
    or arrays of unknown bound.
    If A1, A2,... denotes ArgTypes... and
    raw_invocation_type<Fn(ArgTypes...)>::type
    is the function type R(T1, T2, ...) then let Ui be
    decay<Ai>::type if Ai is an rvalue otherwise Ti.
    If
    and Fn is a pointer to member type and T1 is
    an rvalue reference, then let U1 be R(decay<T1>::type,
    T2, ...)
    .
    Otherwise, raw_invocation_type<Fn(ArgTypes...)>::type
    The member typedef type shall equal R(U1, U2, ...).

[2013-06-21 Rapperswil]

Accept for Fundamentals TS Working Paper

Proposed resolution:

This wording is relative to N4023.

  1. Change Table 3, [meta.trans.other] in the Library TS as indicated:

    Table 3 — Other type transformations
    Template Condition Comments
    template <class Fn, class... ArgTypes>
    struct invocation_type<Fn(ArgTypes...)>;
    Fn and all types in the parameter pack ArgTypes
    shall be complete types, (possibly cv-qualified) void,
    or arrays of unknown bound.
    The nested typedef invocation_type<Fn(ArgTypes...)>::type
    shall be defined as follows. If
    raw_invocation_type<Fn(ArgTypes...)>::type
    does not exist, there shall be no member typedef type. Otherwise:
    • Let A1, A2, … denote ArgTypes...

    • Let R(T1, T2, …) denote
      raw_invocation_type_t<Fn(ArgTypes...)>

    • Then the member typedef type shall name the function
      type R(U1, U2, …) where Ui is decay_t<Ai>
      if declval<Ai>() is an rvalue otherwise Ti.

    If raw_invocation_type<Fn(ArgTypes...)>::type
    is the function type R(T1, T2, …)
    and Fn is a pointer to member type and T1 is
    an rvalue reference, then R(decay<T1>::type,
    T2, …)
    .
    Otherwise, raw_invocation_type<Fn(ArgTypes...)>::type.