2418. [fund.ts] apply does not work with member pointers

Section: 99 [fund.ts::tuple.apply] Status: TS Submitter: Zhihao Yuan Opened: 2014-07-08 Last modified: 2017-07-30

Priority: 0

View all issues with TS status.

Discussion:

Addresses: fund.ts

The definition of apply present in §3.2.2 [tuple.apply] prevents this function template to be used with pointer to members type passed as the first argument.

Effects:

[…]

return std::forward<F>(f)(std::get<I>(std::forward<Tuple>(t))...);

This makes this utility inconsistent with other standard library components and limits its usability.

We propose to define its functionally in terms of INVOKE.

[2015-02, Cologne]

DK: We should use the new std::invoke.
TK: Is this a defect?
AM: std::invoke goes into C++17, and this is a defect against a TS based on C++14. We can change this later, but now leave it as INVOKE.
GR: The TS lets you have Editor's Notes, so leave a note to make that change for C++17.

[…]

GR: I can't see how we can assume this is part of the design. I cannot believe it was ever intended for this design to exclude function pointers.
AM: I can give you the exact evolution: We had "apply" as an example explaining the usefulness of index_sequence. Then someone looked at it and said, "why isn't this in the Standard". NJ to VV: Why are you against useful steps? We are trying to converge on a consistent standard across multiple documents. The alternative is to reopen this in a later discussion.
VV: All I said is that this is not defect, whether or not people like it.
AM: So you'd be fine with the issue, but not as a DR?
Straw poll: Who's happy to make this tentatively ready as a DR against the Fundamentals TS? Lots of agreement, no opposition, 3 neutrals

Proposed resolution:

This wording is relative to N4081 in regard to fundamental-ts changes.

  1. Edit §3.2.2 [tuple.apply] paragraph 2:

    template <class F, class Tuple>
    constexpr decltype(auto) apply(F&& f, Tuple&& t);
    

    -2- Effects: Given the exposition only function

    template <class F, class Tuple, size_t... I>
    constexpr decltype(auto) apply_impl(  // exposition only
        F&& f, Tuple&& t, index_sequence<I...>) {
      return INVOKE(std::forward<F>(f)(, std::get<I>(std::forward<Tuple>(t))...);
    }
    

    […]