<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2022: reference_wrapper&lt;T&gt;::result_type is underspecified</title>
<meta property="og:title" content="Issue 2022: reference_wrapper&lt;T&gt;::result_type is underspecified">
<meta property="og:description" content="C++ library issue. Status: C++11">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2022.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++11">C++11</a> status.</em></p>
<h3 id="2022"><a href="lwg-defects.html#2022">2022</a>. <code>reference_wrapper&lt;T&gt;::result_type</code> is underspecified</h3>
<p><b>Section:</b> 22.10.6 <a href="https://wg21.link/refwrap">[refwrap]</a> <b>Status:</b> <a href="lwg-active.html#C++11">C++11</a>
 <b>Submitter:</b> Daniel Kr&uuml;gler <b>Opened:</b> 2010-12-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#refwrap">issues</a> in [refwrap].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++11">C++11</a> status.</p>
<p><b>Discussion:</b></p>
<p>
Issue <a href="lwg-defects.html#1295" title="Contradictory call wrapper requirements (Status: C++11)">1295</a><sup><a href="https://cplusplus.github.io/LWG/issue1295" title="Latest snapshot">(i)</a></sup> correctly removed function types and references to function types from the
bullet 1 of 22.10.4 <a href="https://wg21.link/func.require">[func.require]</a> p. 3 because neither function types nor function references
satisfy the requirements for a target object which is <em>defined</em> to be an object of a callable 
type. This has the effect that the reference in 22.10.6 <a href="https://wg21.link/refwrap">[refwrap]</a> p. 2
</p>
<blockquote><p>
<code>reference_wrapper</code> has a weak result type (20.8.2).
</p></blockquote>
<p>
is insufficient as a reference to define the member type <code>result_type</code> when the template argument 
<code>T</code> is a function type.
<p/>
There are basically two approaches to solve the problem:
</p>
<ol>
<li><p>Extend the definition of a <i>weak result type</i> in 22.10.4 <a href="https://wg21.link/func.require">[func.require]</a> p. 3 to both
function types and references thereof. This extension must be specified independend from the concept
of a call wrapper, though.</p>
</li>
<li><p>Add one extra sentence to 22.10.6 <a href="https://wg21.link/refwrap">[refwrap]</a> p. 2 that simply defines the member type
<code>result_type</code> for <code>reference_wrapper&lt;T&gt;</code>, when <code>T</code> is a function type.</p>
</li>
</ol>
<p>
I checked the current usages of <i>weak result type</i> to have a base to argue for one or the other
approach. It turns out, that there is no further reference to this definition in regard to
function types or references thereof. The only other reference can be found in 
22.10.15.4 <a href="https://wg21.link/func.bind.bind">[func.bind.bind]</a> p. 3, where <code>g</code> is required to be a class type.
</p>

<p><i>[2011-02-23 Reflector discussion]</i></p>

<p>
Moved to Tentatively Ready after 5 votes.
</p> 


<p id="res-2022"><b>Proposed resolution:</b></p>
<p>
The suggested wording changes are against the working draft N3242.
</p>

<ol>
<li>
<p>Change 22.10.6 <a href="https://wg21.link/refwrap">[refwrap]</a> p. 2 as indicated:</p>

<blockquote><p>
2 <code>reference_wrapper<ins>&lt;T&gt;</ins></code> has a weak result type (20.8.2). <ins>If <code>T</code> is a function type, 
<code>result_type</code> shall be a synonym for the return type of <code>T</code>.</ins>
</p></blockquote>

</li>

</ol>





</body>
</html>
