<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3348: __cpp_lib_unwrap_ref in wrong header</title>
<meta property="og:title" content="Issue 3348: __cpp_lib_unwrap_ref in wrong header">
<meta property="og:description" content="C++ library issue. Status: C++20">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3348.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="3348"><a href="lwg-defects.html#3348">3348</a>. <code>__cpp_lib_unwrap_ref</code> in wrong header</h3>
<p><b>Section:</b> 17.3.2 <a href="https://wg21.link/version.syn">[version.syn]</a>, 99 [refwrap.unwrapref] <b>Status:</b> <a href="lwg-active.html#C++20">C++20</a>
 <b>Submitter:</b> Barry Revzin <b>Opened:</b> 2019-12-03 <b>Last modified:</b> 2021-02-25</p>
<p><b>Priority: </b>2
</p>
<p><b>View other</b> <a href="lwg-index-open.html#version.syn">active issues</a> in [version.syn].</p>
<p><b>View all other</b> <a href="lwg-index.html#version.syn">issues</a> in [version.syn].</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>
cpplearner points out in <a href="https://github.com/BRevzin/sd6/issues/1">this github comment</a> that:
</p>
<blockquote style="border-left: 3px solid #ccc;padding-left: 15px;">
<p>
Since <code>unwrap_reference</code> and <code>unwrap_ref_decay</code> are defined in <code>&lt;functional&gt;</code> 
([functional.syn]), their feature test macro should also be defined there.
</p>
</blockquote>
<p>
<a href="https://wg21.link/p1902r1">P1902R1</a> adds this feature test macro in <code>&lt;type_traits&gt;</code> instead. 
The feature test macro and the type traits should go into the same header: either both in <code>&lt;functional&gt;</code> 
or both in <code>&lt;type_traits&gt;</code>. 
<p/>
The smallest diff is just to move the macro into <code>&lt;functional&gt;</code>.
</p>

<p><i>[2019-12-12 Issue Prioritization]</i></p>

<p>Priority to 2 after reflector discussion.</p>

<strong>Previous resolution [SUPERSEDED]:</strong>
<blockquote class="note">
<p>This wording is relative to <a href="https://wg21.link/n4842">N4842</a>.</p>

<ol>
<li><p>Modify 17.3.2 <a href="https://wg21.link/version.syn">[version.syn]</a> p2 as indicated:</p>
<blockquote>
<pre>
[&hellip;]
#define __cpp_lib_unordered_map_try_emplace 201411L <i>// also in &lt;unordered_map&gt;</i>
#define __cpp_lib_unwrap_ref                201811L <i>// also in &lt;<del>type_traits</del><ins>functional</ins>&gt;</i>
#define __cpp_lib_variant                   201606L <i>// also in &lt;variant&gt;</i>
[&hellip;]
</pre>
</blockquote>
</li>

</ol>
</blockquote>

<p><i>[2020-02-13, Prague]</i></p>

<p>
During LWG discussions it had been suggested that they considered it is an improvement to move the definitions of
<code>unwrap_reference</code> and <code>unwrap_ref_decay</code> from <code>&lt;functional&gt;</code> to <code>&lt;type_traits&gt;</code>.
This is what the alternative wording tries to accomplish.
</p>
<p><i>[Status to Immediate on Thursday night in Prague.]</i></p>



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

<ol>
<li><p>Modify 22.10.2 <a href="https://wg21.link/functional.syn">[functional.syn]</a>, header <code>&lt;functional&gt;</code> synopsis, as indicated:</p>
<blockquote>
<pre>
namespace std {
[&hellip;]
<del>template&lt;class T&gt; struct unwrap_reference;
template&lt;class T&gt; using unwrap_reference_t = typename unwrap_reference&lt;T&gt;::type;
template&lt;class T&gt; struct unwrap_ref_decay;
template&lt;class T&gt; using unwrap_ref_decay_t = typename unwrap_ref_decay&lt;T&gt;::type;</del>
[&hellip;]
}
</pre>
</blockquote>
</li>

<li><p>Delete sub-clause 99 [refwrap.unwrapref] completely, as indicated:</p>
<blockquote>
<p>
<del><b>20.14.5.6 Transformation type trait <code>unwrap_reference</code> [refwrap.unwrapref]</b></del>
</p>
<pre>
<del>template&lt;class T&gt;
  struct unwrap_reference;</del>
</pre>
<blockquote>
<p>
<del>-1- If <code>T</code> is a specialization <code>reference_wrapper&lt;X&gt;</code> for some type <code>X</code>, the member typedef 
<code>type</code> of <code>unwrap_reference&lt;T&gt;</code> is <code>X&amp;</code>, otherwise it is <code>T</code>.</del>
</p>
</blockquote>
<pre>
<del>template&lt;class T&gt;
  struct unwrap_ref_decay;</del>
</pre>
<blockquote>
<p>
<del>-2- The member typedef <code>type</code> of <code>unwrap_ref_decay&lt;T&gt;</code> denotes the type 
<code>unwrap_reference_t&lt;decay_t&lt;T&gt;&gt;</code>.</del>
</p>
</blockquote>
</blockquote>
</li>

<li><p>Modify 21.3.3 <a href="https://wg21.link/meta.type.synop">[meta.type.synop]</a>, header <code>&lt;type_traits&gt;</code> synopsis, as indicated:</p>
<blockquote>
<pre>
namespace std {
[&hellip;]
<i>// 21.3.9.7 <a href="https://wg21.link/meta.trans.other">[meta.trans.other]</a>, other transformations</i>
[&hellip;]
template&lt;class T&gt; struct underlying_type;
template&lt;class Fn, class... ArgTypes&gt; struct invoke_result;
<ins>template&lt;class T&gt; struct unwrap_reference;
template&lt;class T&gt; struct unwrap_ref_decay;</ins>

template&lt;class T&gt;
  using type_identity_t = typename type_identity&lt;T&gt;::type;
[&hellip;]
template&lt;class Fn, class... ArgTypes&gt;
  using invoke_result_t = typename invoke_result&lt;Fn, ArgTypes...&gt;::type;
<ins>template&lt;class T&gt; 
  using unwrap_reference_t = typename unwrap_reference&lt;T&gt;::type;
template&lt;class T&gt; 
  using unwrap_ref_decay_t = typename unwrap_ref_decay&lt;T&gt;::type;</ins>
template&lt;class...&gt;
  using void_t = void;
[&hellip;]
}
</pre>
</blockquote>
</li>

<li><p>Modify 21.3.9.7 <a href="https://wg21.link/meta.trans.other">[meta.trans.other]</a>, Table 55 &mdash; "Sign modifications" in  [tab:meta.trans.sign] as indicated:</p>

<table border="1">
<caption>Table 52 &mdash; Other transformations [tab:meta.trans.other]</caption>
<tr>
<th>Template</th>
<th>Comments</th>
</tr> 

<tr>
<td colspan="2" align="center">
<code>[&hellip;]</code>
</td>
</tr>

<tr>
<td>
<ins><code>template &lt;class T&gt;<br/>
struct unwrap_reference;</code></ins>
</td>
<td>
<ins>If <code>T</code> is a specialization <code>reference_wrapper&lt;X&gt;</code> for some type <code>X</code>, the member typedef 
<code>type</code> of <code>unwrap_reference&lt;T&gt;</code> is <code>X&amp;</code>, otherwise it is <code>T</code>.</ins>
</td>
</tr>

<tr>
<td>
<ins><code>template &lt;class T&gt;<br/>
struct unwrap_ref_decay;</code></ins>
</td>
<td>
<ins>The member typedef <code>type</code> of <code>unwrap_ref_decay&lt;T&gt;</code> denotes the type 
<code>unwrap_reference_t&lt;decay_t&lt;T&gt;&gt;</code>.</ins>
</td>
</tr>
</table>

</li>

<li><p>Insert between 21.3.9.7 <a href="https://wg21.link/meta.trans.other">[meta.trans.other]</a> p1 and p2 as indicated:</p>
<blockquote>
<p>
<ins>In addition to being available via inclusion of the <code>&lt;type_traits&gt;</code> header, the templates 
<code>unwrap_reference</code>, <code>unwrap_ref_decay</code>, <code>unwrap_reference_t</code>, and <code>unwrap_ref_decay_t</code> 
are available when the header <code>&lt;functional&gt;</code> (22.10.2 <a href="https://wg21.link/functional.syn">[functional.syn]</a>) is included.</ins>
</p>
</blockquote>
</li>

</ol>




</body>
</html>
