<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3380: common_type and comparison categories</title>
<meta property="og:title" content="Issue 3380: common_type and comparison categories">
<meta property="og:description" content="C++ library issue. Status: C++20">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3380.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++20">C++20</a> status.</em></p>
<h3 id="3380"><a href="lwg-defects.html#3380">3380</a>. <code>common_type</code> and comparison categories</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#C++20">C++20</a>
 <b>Submitter:</b> Casey Carter <b>Opened:</b> 2020-01-23 <b>Last modified:</b> 2021-02-25</p>
<p><b>Priority: </b>0
</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++20">C++20</a> status.</p>
<p><b>Discussion:</b></p>
<p>
There are two paragraphs in the the definition of <code>common_type</code>:
</p>
<ul>
<li><p>Otherwise, if both <code>D1</code> and <code>D2</code> denote comparison category types 
(17.12.2.1 <a href="https://wg21.link/cmp.categories.pre">[cmp.categories.pre]</a>), let <code>C</code> denote the common comparison type 
(11.10.3 <a href="https://wg21.link/class.spaceship">[class.spaceship]</a>) of <code>D1</code> and <code>D2</code>.</p></li>
<li><p>Otherwise, if <code>decay_t&lt;decltype(false ? declval&lt;D1&gt;() : declval&lt;D2&gt;())&gt;</code> 
denotes a valid type, let <code>C</code> denote that type.</p></li>
</ul>
<p>
<a href="https://wg21.link/p1614r2">P1614R2</a> added the first bullet so that 
<code>common_type_t&lt;strong_equality, T&gt;</code> would be the same type as 
<code>common_comparison_category_t&lt;strong_equality, T&gt;</code>; other cases are correctly handled 
by the second (pre-existing) bullet. After application of <a href="https://wg21.link/p1959r0">P1959R0</a> 
in Belfast, <code>std::strong_equality</code> is no more. We can now strike the first bullet without 
changing the behavior of <code>common_type</code>.
</p>

<p><i>[2020-02-08 Status set to Tentatively Ready after seven positive votes on the reflector.]</i></p>



<p id="res-3380"><b>Proposed resolution:</b></p>
<p>This wording is relative to <a href="https://wg21.link/n4849">N4849</a>.</p>

<ol>
<li><p>Modify 21.3.9.7 <a href="https://wg21.link/meta.trans.other">[meta.trans.other]</a> as indicated:</p>

<blockquote>
<p>
-3- Note A: For the <code>common_type</code> trait applied to a template 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; [&hellip;]</p></li>
<li><p>[&hellip;]</p></li>
<li><p>(3.3) &mdash; If <code>sizeof...(T)</code> is two, let the first and second types constituting <code>T</code> 
be denoted by <code>T1</code> and <code>T2</code>, respectively, and let <code>D1</code> and <code>D2</code> denote the 
same types as <code>decay_t&lt;T1&gt;</code> and <code>decay_t&lt;T2&gt;</code>, respectively.</p>
<ol style="list-style-type: none">
<li><p>(3.3.1) &mdash; If <code>is_same_v&lt;T1, D1&gt;</code> is <code>false</code> or <code>is_same_v&lt;T2, D2&gt;</code> 
is <code>false</code>, let <code>C</code> denote the same type, if any, as <code>common_type_t&lt;D1, D2&gt;</code>.</p></li>
<li><p>(3.3.2) &mdash; [<i>Note:</i> None of the following will apply if there is a specialization 
<code>common_type&lt;D1, D2&gt;</code>. &mdash; <i>end note</i>]</p></li>
<li><p><del>(3.3.3) &mdash; Otherwise, if both <code>D1</code> and <code>D2</code> denote comparison category types 
(17.12.2.1 <a href="https://wg21.link/cmp.categories.pre">[cmp.categories.pre]</a>), let <code>C</code> denote the common comparison type 
(11.10.3 <a href="https://wg21.link/class.spaceship">[class.spaceship]</a>) of <code>D1</code> and <code>D2</code>.</del></p></li>
<li><p>(3.3.4) &mdash; Otherwise, if</p>
<blockquote><pre>
decay_t&lt;decltype(false ? declval&lt;D1&gt;() : declval&lt;D2&gt;())>
</pre></blockquote>
<p>
denotes a valid type, let <code>C</code> denote that type.</p></li>
<li><p>(3.3.5) &mdash; [&hellip;]</p></li>
</ol>
</li>
<li><p>[&hellip;]</p></li>
</ol>
</blockquote>
</li>
</ol>





</body>
</html>
