<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2545: Simplify wording for bind without explicitly specified return type</title>
<meta property="og:title" content="Issue 2545: Simplify wording for bind without explicitly specified return type">
<meta property="og:description" content="C++ library issue. Status: C++17">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2545.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#C++17">C++17</a> status.</em></p>
<h3 id="2545"><a href="lwg-defects.html#2545">2545</a>. Simplify wording for <code>bind</code> without explicitly specified return type</h3>
<p><b>Section:</b> 22.10.15.4 <a href="https://wg21.link/func.bind.bind">[func.bind.bind]</a> <b>Status:</b> <a href="lwg-active.html#C++17">C++17</a>
 <b>Submitter:</b> Tomasz Kami&nacute;ski <b>Opened:</b> 2015-10-05 <b>Last modified:</b> 2017-07-30</p>
<p><b>Priority: </b>3
</p>
<p><b>View all other</b> <a href="lwg-index.html#func.bind.bind">issues</a> in [func.bind.bind].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++17">C++17</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The specification of the <code>bind</code> overload without return type as of 22.10.15.4 <a href="https://wg21.link/func.bind.bind">[func.bind.bind]</a> p3, 
uses the following expression <code><i>INVOKE</i>(fd, std::forward&lt;V1&gt;(v1), std::forward&lt;V2&gt;(v2), ..., 
std::forward&lt;VN&gt;(vN), result_of_t&lt;FD <i>cv</i> &amp; (V1, V2, ..., VN)&gt;)</code> to describe effects of 
invocation of returned function.
<p/>
According to the definition from 21.3.9.7 <a href="https://wg21.link/meta.trans.other">[meta.trans.other]</a> <code>result_of_t&lt;FD cv &amp; (V1, V2, ..., VN)></code> 
is equivalent to 
<code>decltype(INVOKE(declval&lt;FD <i>cv</i> &amp;&gt;(), declval&lt;V1&gt;(), declval&lt;V2&gt;(), ..., declval&lt;VN&gt;()))</code>. 
When combined with the definition of <code><i>INVOKE</i></code> from 22.10.4 <a href="https://wg21.link/func.require">[func.require]</a> p2, the expression 
<code><i>INVOKE</i>(fd, std::forward&lt;V1&gt;(v1), std::forward&lt;V2&gt;(v2), ..., std::forward&lt;VN&gt;(vN), 
result_of_t&lt;FD <i>cv</i> &amp; (V1, V2, ...., VN)&gt;)</code> is equivalent to <code><i>INVOKE</i>(fd, 
std::forward&lt;V1&gt;(v1), std::forward&lt;V2&gt;(v2), ..., std::forward&lt;VN&gt;(vN))</code> implicitly converted 
to <code>decltype(<i>INVOKE</i>(declval&lt;FD <i>cv</i> &amp;&gt;(), declval&lt;V1&gt;(), declval&lt;V2&gt;(), ..., 
declval&lt;VN&gt;()))</code> (itself).
<p/>
It is also worth to notice that specifying the result type (<code>R</code>) in <code><i>INVOKE</i>(f, args..., R)</code> does 
not in any way affect the selected call. As a consequence the use of wording of the form
<code><i>INVOKE</i>(fd, std::forward&lt;V1&gt;(v1), std::forward&lt;V2&gt;(v2), ..., std::forward&lt;VN&gt;(vN), 
result_of_t&lt;FD <i>cv</i> &amp; (V1, V2, ..., VN)&gt;)</code> does not and cannot lead to call of different overload 
than one invoked by <code><i>INVOKE</i>(fd, std::forward&lt;V1&gt;(v1), std::forward&lt;V2&gt;(v2), ..., 
std::forward&lt;VN&gt;(vN))</code>.
<p/>
In summary the form <code><i>INVOKE</i>(fd, std::forward&lt;V1&gt;(v1), std::forward&lt;V2&gt;(v2), ..., 
std::forward&lt;VN&gt;(vN), result_of_t&lt;FD <i>cv</i> &amp; (V1, V2, ..., VN)&gt;)</code> is a convoluted way of expressing 
<code><i>INVOKE</i>(fd, std::forward&lt;V1&gt;(v1), std::forward&lt;V2&gt;(v2), ..., std::forward&lt;VN&gt;(vN))</code>, 
that only confuses reader.
</p>

<p><i>[2015-10, Kona Saturday afternoon]</i></p>

<p>STL: I most recently reimplemented std::bind from scratch, and I think this issue is correct and the solution is good.</p>
<p>Move to Tentatively ready.</p>


<p id="res-2545"><b>Proposed resolution:</b></p>
<p>This wording is relative to N4527.</p>

<ol>
<li>
<p>Change 22.10.15.4 <a href="https://wg21.link/func.bind.bind">[func.bind.bind]</a> p3 as indicated:</p>
<blockquote>
<pre>
template&lt;class F, class... BoundArgs&gt;
<i>unspecified</i> bind(F&amp;&amp; f, BoundArgs&amp;&amp;... bound_args);
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-3- <i>Returns</i>: A forwarding call wrapper <code>g</code> with a weak result type (20.9.2). The effect of 
<code>g(u1, u2, ..., uM)</code> shall be <code><i>INVOKE</i>(fd, std::forward&lt;V1&gt;(v1), std::forward&lt;V2&gt;(v2), 
..., std::forward&lt;VN&gt;(vN)<del>, result_of_t&lt;FD <i>cv</i> &amp; (V1, V2, ..., VN)&gt;</del>)</code>, where <del><code><i>cv</i></code>
represents the <i>cv</i>-qualifiers of <code>g</code> and</del> the values and types of the bound arguments <code>v1, v2, ..., vN</code> 
are determined as specified below. The copy constructor and move constructor of the forwarding call wrapper shall 
throw an exception if and only if the corresponding constructor of <code>FD</code> or of any of the types <code>TiD</code> 
throws an exception.
<p/>
[&hellip;]
</p>
</blockquote>
</blockquote>
</li>
</ol>





</body>
</html>
