<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 816: Should bind()'s returned functor have a nofail copy ctor when bind() is nofail?</title>
<meta property="og:title" content="Issue 816: Should bind()'s returned functor have a nofail copy ctor when bind() is nofail?">
<meta property="og:description" content="C++ library issue. Status: Resolved">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue816.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#Resolved">Resolved</a> status.</em></p>
<h3 id="816"><a href="lwg-defects.html#816">816</a>. Should <code>bind()</code>'s returned functor have a nofail copy ctor when <code>bind()</code> is nofail?</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#Resolved">Resolved</a>
 <b>Submitter:</b> Stephan T. Lavavej <b>Opened:</b> 2008-02-08 <b>Last modified:</b> 2016-01-28</p>
<p><b>Priority: </b>Not Prioritized
</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#Resolved">Resolved</a> status.</p>
<p><b>Discussion:</b></p>
<p>
Library Issue <a href="lwg-defects.html#527" title="tr1::bind has lost its Throws clause (Status: CD1)">527</a><sup><a href="https://cplusplus.github.io/LWG/issue527" title="Latest snapshot">(i)</a></sup> notes that <code>bind(f, t1, ..., tN)</code>
should be nofail when <code>f, t1, ..., tN</code> have nofail copy ctors.
</p>
<p>
However, no guarantees are provided for the copy ctor of the functor
returned by <code>bind()</code>.  (It's guaranteed to have a copy ctor, which can
throw implementation-defined exceptions: <code>bind()</code> returns a forwarding
call wrapper, TR1 3.6.3/2.  A forwarding call wrapper is a call wrapper,
TR1 3.3/4.  Every call wrapper shall be CopyConstructible, TR1 3.3/4.
Everything without an exception-specification may throw
implementation-defined exceptions unless otherwise specified, C++03
17.4.4.8/3.)
</p>
<p>
Should the nofail guarantee requested by Library Issue <a href="lwg-defects.html#527" title="tr1::bind has lost its Throws clause (Status: CD1)">527</a><sup><a href="https://cplusplus.github.io/LWG/issue527" title="Latest snapshot">(i)</a></sup> be extended
to cover both calling <code>bind()</code> and copying the returned functor?
</p>

<p><i>[
Howard adds:
]</i></p>


<blockquote><p>
<code>tuple</code> construction should probably have a similar guarantee.
</p></blockquote>

<p><i>[
San Francisco:
]</i></p>


<blockquote><p>
Howard to provide wording.
</p></blockquote>

<p><i>[
Post Summit, Anthony provided wording.
]</i></p>


<p><i>[
Batavia (2009-05):
]</i></p>

<blockquote><p>
Part of all of this issue appears to be rendered moot
by the proposed resolution to issue <a href="lwg-defects.html#817" title="bind needs to be moved (Status: C++11)">817</a><sup><a href="https://cplusplus.github.io/LWG/issue817" title="Latest snapshot">(i)</a></sup> (q.v.).
We recommend the issues be considered simultaneously
(or possibly even merged)
to ensure there is no overlap.
Move to Open, and likewise for issue <a href="lwg-defects.html#817" title="bind needs to be moved (Status: C++11)">817</a><sup><a href="https://cplusplus.github.io/LWG/issue817" title="Latest snapshot">(i)</a></sup>.
</p></blockquote>

<p><i>[
2009-07 Frankfurt:
]</i></p>


<blockquote><p>
Related to <a href="lwg-defects.html#817" title="bind needs to be moved (Status: C++11)">817</a><sup><a href="https://cplusplus.github.io/LWG/issue817" title="Latest snapshot">(i)</a></sup> (see below). Leave Open.
</p></blockquote>

<p><i>[
2009-10 Santa Cruz:
]</i></p>


<blockquote><p>
Move to Ready. Decoupling from issue <a href="lwg-defects.html#817" title="bind needs to be moved (Status: C++11)">817</a><sup><a href="https://cplusplus.github.io/LWG/issue817" title="Latest snapshot">(i)</a></sup>.
</p></blockquote>

<p><i>[
2010-02-11 Moved from Ready to Tentatively NAD Editorial, rationale added below.
]</i></p>




<p><b>Rationale:</b></p>
<p>
This issue is solved as proposed by <a href="lwg-defects.html#817" title="bind needs to be moved (Status: C++11)">817</a><sup><a href="https://cplusplus.github.io/LWG/issue817" title="Latest snapshot">(i)</a></sup>.
</p>


<p id="res-816"><b>Proposed resolution:</b></p>
<p>
Add a new sentence to the end of paragraphs 2 and 4 of 22.10.15.4 <a href="https://wg21.link/func.bind.bind">[func.bind.bind]</a>:
</p>

<blockquote>
<p>
-2- <i>Returns:</i> A forwarding call wrapper <code>g</code> with a weak result type (20.6.2). The effect of <code>g(u1, u2,
..., uM)</code> shall be <code><i>INVOKE</i>(f, v1, v2, ..., vN, Callable&lt;F cv,V1, V2, ..., VN&gt;::result_type)</code>, where <i>cv</i>
represents the <i>cv</i>-qualifiers of <code>g</code> and the values and types of the bound arguments
<code>v1, v2, ..., vN</code> are determined as specified below.
<ins>The copy constructor and move constructor of the forwarding call wrapper shall throw an
exception if and only if the corresponding constructor of <code>F</code> or any of the types
in <code>BoundArgs...</code> throw an exception.</ins>
</p>
<p>...</p>
<p>
-5- <i>Returns:</i> A forwarding call wrapper <code>g</code> with a nested type <code>result_type</code> defined as a synonym
for <code>R</code>. The effect of <code>g(u1, u2, ..., uM)</code> shall be <code><i>INVOKE</i>(f, v1, v2, ..., vN, R)</code>, where the
values and types of the bound arguments <code>v1, v2, ..., vN</code> are determined as specified below.
<ins>The copy constructor and move constructor of the forwarding call wrapper shall throw an
exception if and only if the corresponding constructor of <code>F</code> or any of the types
in <code>BoundArgs...</code> throw an exception.</ins>
</p>

</blockquote>





</body>
</html>
