<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2418: [fund.ts] apply does not work with member pointers</title>
<meta property="og:title" content="Issue 2418: [fund.ts] apply does not work with member pointers">
<meta property="og:description" content="C++ library issue. Status: TS">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2418.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#TS">TS</a> status.</em></p>
<h3 id="2418"><a href="lwg-defects.html#2418">2418</a>. [fund.ts] <code>apply</code> does not work with member pointers</h3>
<p><b>Section:</b> 3.2.2 <a href="https://cplusplus.github.io/fundamentals-ts/v1.html#tuple.apply">[fund.ts::tuple.apply]</a> <b>Status:</b> <a href="lwg-active.html#TS">TS</a>
 <b>Submitter:</b> Zhihao Yuan <b>Opened:</b> 2014-07-08 <b>Last modified:</b> 2017-07-30</p>
<p><b>Priority: </b>0
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#TS">TS</a> status.</p>
<p><b>Discussion:</b></p>
<p><b>Addresses: fund.ts</b></p>
<p>
The definition of <code>apply</code> present in &sect;3.2.2 [tuple.apply] prevents this
function template to be used with pointer to members type passed as the first argument.
</p>
<blockquote>
<i>Effects:</i> 
<p/>
[&hellip;]
<p/>
<code>return std::forward&lt;F&gt;(f)(std::get&lt;I&gt;(std::forward&lt;Tuple&gt;(t))...);</code>
</blockquote>
<p>
This makes this utility inconsistent with other standard library components and limits its usability.
<p/>
We propose to define its functionally in terms of <code><i>INVOKE</i></code>.
</p>

<p><i>[2015-02, Cologne]</i></p>

<p>
DK: We should use the new <code>std::invoke</code>.<br/> 
TK: Is this a defect?<br/> 
AM: <code>std::invoke</code> 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.<br/> 
GR: The TS lets you have Editor's Notes, so leave a note to make that change for C++17.
<p/>
[&hellip;]
<p/>
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.<br/>  
AM: I can give you the exact evolution: We had "apply" as an example explaining the usefulness of <code>index_sequence</code>. 
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.<br/>  
VV: All I said is that this is not defect, whether or not people like it.<br/>  
AM: So you'd be fine with the issue, but not as a DR?<br/> 
Straw poll: Who's happy to make this tentatively ready as a DR against the Fundamentals TS? 
Lots of agreement, no opposition, 3 neutrals
</p>


<p id="res-2418"><b>Proposed resolution:</b></p>
<p>This wording is relative to <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4081.html">N4081</a> 
in regard to fundamental-ts changes.</p>

<ol>
<li><p>Edit &sect;3.2.2 [tuple.apply] paragraph 2:</p>

<blockquote>
<pre>
template &lt;class F, class Tuple&gt;
constexpr decltype(auto) apply(F&amp;&amp; f, Tuple&amp;&amp; t);
</pre>
<blockquote>
<p>
-2- <i>Effects</i>: Given the exposition only function
</p>
<blockquote>
<pre>
template &lt;class F, class Tuple, size_t... I&gt;
constexpr decltype(auto) apply_impl(  // <i>exposition only</i>
    F&amp;&amp; f, Tuple&amp;&amp; t, index_sequence&lt;I...&gt;) {
  return <ins><i>INVOKE</i>(</ins>std::forward&lt;F&gt;(f)<del>(</del><ins>, </ins>std::get&lt;I&gt;(std::forward&lt;Tuple&gt;(t))...);
}
</pre>
<p>
[&hellip;]
</p>
</blockquote>
</blockquote>
</blockquote>
</li>
</ol>





</body>
</html>
