<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2390: [fund.ts] Invocation types and rvalues</title>
<meta property="og:title" content="Issue 2390: [fund.ts] Invocation types and rvalues">
<meta property="og:description" content="C++ library issue. Status: TS">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2390.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="2390"><a href="lwg-defects.html#2390">2390</a>. [fund.ts] Invocation types and rvalues</h3>
<p><b>Section:</b> 3.3.2 <a href="https://cplusplus.github.io/fundamentals-ts/v1.html#meta.trans.other">[fund.ts::meta.trans.other]</a> <b>Status:</b> <a href="lwg-active.html#TS">TS</a>
 <b>Submitter:</b> Michael Spertus <b>Opened:</b> 2014-05-26 <b>Last modified:</b> 2017-07-30</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all other</b> <a href="lwg-index.html#fund.ts::meta.trans.other">issues</a> in [fund.ts::meta.trans.other].</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>
<code>invocation_type</code> falls short of its stated goals in the following case. Using the notation of 
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3866.html">Invocation type traits</a>, 
consider
</p>
<blockquote>
<pre>
void f(int const&amp; i);
more_perfect_forwarding_async(f, int(7)); // Oops. Dangling reference because rvalue gone when async runs
</pre>
</blockquote>
<p>
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.
</p>

<p><i>[2014-06-18, Rapperswil]</i></p>

<p>
Mike Spertus, Richard Smith, Jonathan Wakely, and Jeffrey Yasskin suggest improved wording.
</p>

<strong>Previous resolution [SUPERSEDED]:</strong>
<p/>
<blockquote class="note">
<p>This wording is relative to <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3908.html">N3908</a>.</p>

<ol>
<li><p>Change Table 3, [meta.trans.other] in the <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3908.html#meta.trans.other">Library TS</a> 
as indicated:
</p>
<blockquote>
<table border="1">
<caption>Table 3 &mdash; Other type transformations</caption>
<tr>
<th align="center">Template</th>
<th align="center">Condition</th>
<th align="center">Comments</th>
</tr>

<tr>
<td colspan="3" align="center">
<code>&hellip;</code>
</td>
</tr>

<tr>
<td>
<code>template &lt;class Fn, class... ArgTypes&gt;<br/>
struct invocation_type&lt;Fn(ArgTypes...)&gt;;</code>
</td>
<td>
<code>Fn</code> and all types in the parameter pack <code>ArgTypes</code><br/>
shall be complete types, (possibly <i>cv</i>-qualified) <code>void</code>,<br/> 
or arrays of unknown bound. 
</td>
<td>
If <ins><code>A1, A2,...</code> denotes <code>ArgTypes...</code> and</ins><br/> 
<code>raw_invocation_type&lt;Fn(ArgTypes...)&gt;::type</code><br/> 
is the function type <code>R(T1, T2, ...)</code> <ins>then let <code>Ui</code> be<br/> 
<code>decay&lt;Ai&gt;::type</code> if <code>Ai</code> is an rvalue otherwise <code>Ti</code>.<br/> 
If</ins> <del>and</del> <code>Fn</code> is a pointer to member type and <code>T1</code> is<br/>
an rvalue reference, then <ins>let <code>U1</code> be</ins> <code><del>R(</del>decay&lt;T1&gt;::type<del>,<br/> 
T2, ...)</del></code>.<br/> 
<del>Otherwise, <code>raw_invocation_type&lt;Fn(ArgTypes...)&gt;::type</code></del><br/>
<ins>The member typedef <code>type</code> shall equal <code>R(U1, U2, ...)</code></ins>.
</td>
</tr>

</table>
</blockquote>

</li>
</ol>
</blockquote>

<p><i>[2013-06-21 Rapperswil]</i></p>

<p>
Accept for Fundamentals TS Working Paper
</p>


<p id="res-2390"><b>Proposed resolution:</b></p>
<p>This wording is relative to <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4023.html">N4023</a>.</p>

<ol>
<li><p>Change Table 3, [meta.trans.other] in the <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4023.html#meta.trans.other">Library TS</a> 
as indicated:
</p>
<blockquote>
<table border="1">
<caption>Table 3 &mdash; Other type transformations</caption>
<tr>
<th align="center">Template</th>
<th align="center">Condition</th>
<th align="center">Comments</th>
</tr>

<tr>
<td colspan="3" align="center">
<code>&hellip;</code>
</td>
</tr>

<tr>
<td>
<code>template &lt;class Fn, class... ArgTypes&gt;<br/>
struct invocation_type&lt;Fn(ArgTypes...)&gt;;</code>
</td>
<td>
<code>Fn</code> and all types in the parameter pack <code>ArgTypes</code><br/>
shall be complete types, (possibly <i>cv</i>-qualified) <code>void</code>,<br/> 
or arrays of unknown bound. 
</td>
<td>
<ins>
The nested typedef <code>invocation_type&lt;Fn(ArgTypes...)&gt;::type</code><br/> 
shall be defined as follows. If<br/>
<code>raw_invocation_type&lt;Fn(ArgTypes...)&gt;::type</code><br/> 
does not exist, there shall be no member typedef <code>type</code>. Otherwise:<br/>
<ul>
<li><p><ins>Let <code>A1, A2,</code> &hellip; denote <code>ArgTypes...</code></ins></p></li>
<li><p><ins>Let <code>R(T1, T2, &hellip;)</code> denote<br/>
<code>raw_invocation_type_t&lt;Fn(ArgTypes...)&gt;</code></ins></p></li>
<li><p><ins>Then the member typedef <code>type</code> shall name the function<br/>
type <code>R(U1, U2, &hellip;)</code> where <code>Ui</code> is <code>decay_t&lt;Ai&gt;</code><br/> 
if <code>declval&lt;Ai&gt;()</code> is an rvalue otherwise <code>Ti</code>.</ins></p></li>
</ul>
</ins>
<del>If <code>raw_invocation_type&lt;Fn(ArgTypes...)&gt;::type</code><br/> 
is the function type <code>R(T1, T2, &hellip;)</code> <br/> 
and <code>Fn</code> is a pointer to member type and <code>T1</code> is<br/>
an rvalue reference, then <code>R(decay&lt;T1&gt;::type,<br/> 
T2, &hellip;)</code>.<br/> 
Otherwise, <code>raw_invocation_type&lt;Fn(ArgTypes...)&gt;::type</code>.<br/></del>
</td>
</tr>

</table>
</blockquote>

</li>
</ol>





</body>
</html>
