<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2763: common_type_t&lt;void, void&gt; is undefined</title>
<meta property="og:title" content="Issue 2763: common_type_t&lt;void, void&gt; is undefined">
<meta property="og:description" content="C++ library issue. Status: Resolved">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2763.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="2763"><a href="lwg-defects.html#2763">2763</a>. <code>common_type_t&lt;void, void&gt;</code> is undefined</h3>
<p><b>Section:</b> 21.3.9.7 <a href="https://wg21.link/meta.trans.other">[meta.trans.other]</a> <b>Status:</b> <a href="lwg-active.html#Resolved">Resolved</a>
 <b>Submitter:</b> Tim Song <b>Opened:</b> 2016-08-10 <b>Last modified:</b> 2016-11-21</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#Resolved">Resolved</a> status.</p>
<p><b>Discussion:</b></p>
<p>
There are no xvalues of type <i>cv</i> <code>void</code> (see [basic.lval]/6), so the current wording appears 
to mean that there is no <code>common_type_t&lt;void, void&gt;</code>. Is that intended?
</p>

<p><i>[2016-08-11, Daniel comments]</i></p>

<p>
This is strongly related to LWG <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>. It should be considered to resolve <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>
by this revised wording.
</p>

<p><i>[2016-11-12, Issaquah]</i></p>

<p>Resolved by P0435R1</p>


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

<ol>
<li><p>Edit 21.3.9.7 <a href="https://wg21.link/meta.trans.other">[meta.trans.other]</a>/3 as indicated:</p>
<blockquote class="note">
<p>
[<i>Drafting note</i>: The proposed wording below simply goes back to using <code>declval</code>, which already does the right 
thing. To describe this in words would be something like "if <code>D1</code> is <code>void</code>, a prvalue of type 
<code>void</code> that is not a (possibly parenthesized) <i>throw-expression</i>, otherwise an xvalue of type <code>D1</code>", which 
seems unnecessarily convoluted at best. &mdash; <i>end drafting note</i>]
</p>
</blockquote>
<blockquote>
<p>
For the <code>common_type</code> trait applied to a parameter pack <code>T</code> of types, the member <code>type</code> 
shall be either defined or not present as follows:
</p>
<ol style="list-style-type: none">
<li><p>(3.1) &mdash; If <code>sizeof...(T)</code> is zero, there shall be no member <code>type</code>.</p></li>
<li><p>(3.2) &mdash; If <code>sizeof...(T)</code> is one, let <code>T0</code> denote the sole type in the pack <code>T</code>. 
The member typedef <code>type</code> shall denote the same type as <code>decay_t&lt;T0&gt;</code>.</p></li>
<li><p>(3.3) &mdash; If <code>sizeof...(T)</code> is greater than two, let <code>T1</code>, <code>T2</code>, and <code>R</code>, 
respectively, denote the first, second, and (pack of) remaining types comprising <code>T</code>. 
[<i>Note:</i> <code>sizeof...(R)</code> may be zero. &mdash; <i>end note</i>] Let <code>C</code> denote the
type, if any, of an unevaluated conditional expression (7.6.16 <a href="https://wg21.link/expr.cond">[expr.cond]</a>) whose first operand is an arbitrary value
of type <code>bool</code>, whose second operand is <del>an xvalue of type <code>T1</code></del><ins><code>declval&lt;T1&gt;()</code></ins>,
and whose third operand is <del>an xvalue of type <code>T2</code></del><ins><code>declval&lt;T2&gt;()</code></ins>. If there is 
such a type <code>C</code>, the member typedef <code>type</code> shall denote the same type, if any, 
as <code>common_type_t&lt;C, R...&gt;</code>. Otherwise, there shall be no member <code>type</code>.</p></li>
</ol>
</blockquote>
</li>
<li><p> The following wording is a merge of the above with the current proposed resolution of <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>, to provide 
editorial guidance if both proposed resolutions are accepted:</p>

<blockquote>
<p>
-3- <ins>Note A:</ins> For the <code>common_type</code> trait applied to a parameter pack <code>T</code> of types, the 
member <code>type</code> shall be either defined or not present as follows:
</p>
<ol style="list-style-type: none">
<li><p>(3.1) &mdash; If <code>sizeof...(T)</code> is zero, there shall be no member <code>type</code>.</p></li>
<li><p>(3.2) &mdash; If <code>sizeof...(T)</code> is one, let <code>T0</code> denote the sole type in the pack <code>T</code>. 
The member typedef <code>type</code> shall denote the same type as <code>decay_t&lt;T0&gt;</code>.</p></li>
<li><p>(3.3) &mdash; <ins>If <code>sizeof...(T)</code> is two, let <code>T1</code> and <code>T2</code>, respectively,
denote the first and second types comprising <code>T</code>, and let <code>D1</code> and <code>D2</code>, 
respectively, denote <code>decay_t&lt;T1&gt;</code> and <code>decay_t&lt;T2&gt;</code>.</ins></p>
<ol style="list-style-type: none">
<li><p>(3.3.1) &mdash; <ins>If <code>is_same_v&lt;T1, D1&gt;</code> and <code>is_same_v&lt;T2, D2&gt;</code>,
let <code>C</code> denote the type of an unevaluated conditional expression (7.6.16 <a href="https://wg21.link/expr.cond">[expr.cond]</a>)
whose first operand is an arbitrary value of type <code>bool</code>,
whose second operand is <code>declval&lt;D1&gt;()</code>,
and whose third operand is <code>declval&lt;D2&gt;()</code>.
[<i>Note:</i> This will not apply if there is a specialization <code>common_type&lt;D1, D2&gt;</code>. &mdash; 
<i>end note</i>]</ins></p></li>
<li><p>(3.3.2) &mdash; <ins>Otherwise, let <code>C</code> denote the type
<code>common_type_t&lt;D1, D2&gt;</code>.</ins></p></li>
</ol>
<p><ins> In either case, if there is such a type <code>C</code>,
the member typedef <code>type</code> shall denote <code>C</code>.
Otherwise, there shall be no member <code>type</code>.</ins></p>
</li>
<li><p>(3.4) &mdash; If <code>sizeof...(T)</code> is greater than <del>one</del><ins>two</ins>, let <code>T1</code>, <code>T2</code>, and 
<code>R</code>, 
respectively, denote the first, second, and (pack of) remaining types comprising <code>T</code>. 
<del>[<i>Note:</i> <code>sizeof...(R)</code> may be zero. &mdash; <i>end note</i>] Let <code>C</code> denote the
type, if any, of an unevaluated conditional expression (7.6.16 <a href="https://wg21.link/expr.cond">[expr.cond]</a>) whose first operand is an arbitrary value
of type <code>bool</code>, whose second operand is an xvalue of type <code>T1</code>, and whose third operand is 
an xvalue of type <code>T2</code>.</del> <ins>Let <code>C</code> denote <code>common_type_t&lt;T1, T2&gt;</code>.</ins> 
If there is such a type <code>C</code>, the member typedef <code>type</code> 
shall denote the same type, if any, as <code>common_type_t&lt;C, R...&gt;</code>. Otherwise, there shall 
be no member <code>type</code>.</p></li>
</ol>
<p>
<ins>-?- Note B: A program may specialize the <code>common_type</code> trait for two <i>cv</i>-unqualified 
non-reference types if at least one of them is a user-defined type. [<i>Note:</i> Such specializations are
needed when only explicit conversions are desired among the template
arguments. &mdash; <i>end note</i>] Such a specialization need not have a member named <code>type</code>,
but if it does, that member shall be a <i>typedef-name</i> for a <i>cv</i>-unqualified non-reference type
that need not otherwise meet the specification set forth in Note A, above.</ins>
<p/>
-4- [<i>Example:</i> Given these definitions: [&hellip;]
</p>
</blockquote>
</li>
</ol>







</body>
</html>
