<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2460: LWG issue 2408 and value categories</title>
<meta property="og:title" content="Issue 2460: LWG issue 2408 and value categories">
<meta property="og:description" content="C++ library issue. Status: C++17">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2460.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="2460"><a href="lwg-defects.html#2460">2460</a>. LWG issue 2408 and value categories</h3>
<p><b>Section:</b> 21.3.9.7 <a href="https://wg21.link/meta.trans.other">[meta.trans.other]</a>, 24.3.2.3 <a href="https://wg21.link/iterator.traits">[iterator.traits]</a> <b>Status:</b> <a href="lwg-active.html#C++17">C++17</a>
 <b>Submitter:</b> Richard Smith <b>Opened:</b> 2014-11-19 <b>Last modified:</b> 2017-07-30</p>
<p><b>Priority: </b>2
</p>
<p><b>View all other</b> <a href="lwg-index.html#meta.trans.other">issues</a> in [meta.trans.other].</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>
LWG issue <a href="lwg-defects.html#2408" title="SFINAE-friendly common_type/iterator_traits is missing in C++14 (Status: C++17)">2408</a><sup><a href="https://cplusplus.github.io/LWG/issue2408" title="Latest snapshot">(i)</a></sup> changes the meat of the specification of <code>common_type</code> to compute:
</p>
<blockquote><p>
[&hellip;] the type, if any, of an unevaluated conditional expression (5.16) whose first operand is an 
arbitrary value of type <code>bool</code>, whose second operand is an <code>xvalue</code> of type <code>T1</code>, 
and whose third operand is an xvalue of type <code>T2</code>.
</p></blockquote>
<p>
This has an effect on the specification that I think was unintended. It used to be the case that 
<code>common_type&lt;T&amp;, U&amp;&amp;&gt;</code> would consider the type of a conditional between an 
lvalue of type <code>T</code> and an xvalue of type <code>U</code>. It's now either invalid (because there is 
no such thing as an xvalue of reference type) or considers the type of a conditional between an xvalue 
of type <code>T</code> and an xvalue of type <code>U</code>, depending on how you choose to read it.
<p/>
Put another way, this has the effect of changing the usual definition from:
</p>
<blockquote><pre>
typedef decay_t&lt;decltype(true ? declval&lt;T&gt;() : declval&lt;U&gt;())&gt; type;
</pre></blockquote>
<p>
to:
</p>
<blockquote><pre>
typedef decay_t&lt;decltype(true ? declval&lt;remove_reference_t&lt;T&gt;&gt;() : declval&lt;remove_reference_t&lt;U&gt;&gt;())&gt; type;
</pre></blockquote>
<p>
It also makes <code>common_type</code> underspecified in the case where one of the operands is of type <code>void</code>; 
in that case, the resulting type depends on whether the expression is a throw-expression, which is not 
specified (but used to be).
<p/>
Also on the subject of this wording: the changes to 24.3.2.3 <a href="https://wg21.link/iterator.traits">[iterator.traits]</a> say that 
<code>iterator_traits&lt;T&gt;</code> "shall have no members" in some cases. That's wrong. It's a class type; 
it always has at least a copy constructor, a copy assignment operator, and a destructor. Plus this 
removes the usual library liberty to add additional members with names that don't collide with normal 
usage (for instance, if a later version of the standard adds members, they can't be present here as a 
conforming extension). Perhaps this should instead require that the class doesn't have members with any 
of those five names? That's what <a href="lwg-defects.html#2408" title="SFINAE-friendly common_type/iterator_traits is missing in C++14 (Status: C++17)">2408</a><sup><a href="https://cplusplus.github.io/LWG/issue2408" title="Latest snapshot">(i)</a></sup> does for <code>common_type</code>'s type member.
</p>

<p><i>[2016-08 Chicago]</i></p>

<p>This issue has two parts, one dealing with <code>common_type</code>, the other with <code>iterator_traits</code>. 
The first of these is resolved by <a href="lwg-defects.html#2465" title="SFINAE-friendly common_type is nearly impossible to specialize
correctly and regresses key functionality (Status: Resolved)">2465</a><sup><a href="https://cplusplus.github.io/LWG/issue2465" title="Latest snapshot">(i)</a></sup>.  See below for the proposed resolution for the other one.</p>
<p>Wed PM: Move to Tentatively Ready</p>


<p id="res-2460"><b>Proposed resolution:</b></p>
<p>Change 24.3.2.3 <a href="https://wg21.link/iterator.traits">[iterator.traits]</a> p.2:</p>

<p>[&hellip;] as publicly accessible members <del>and no other members</del>:</p>

<p>[&hellip;]</p>

<p>Otherwise, <code>iterator_traits&lt;Iterator&gt;</code> shall have no members <ins>by any of the above names</ins>.</p>





</body>
</html>
