<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 706: make_pair() should behave as make_tuple() wrt. reference_wrapper()</title>
<meta property="og:title" content="Issue 706: make_pair() should behave as make_tuple() wrt. reference_wrapper()">
<meta property="og:description" content="C++ library issue. Status: CD1">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue706.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#CD1">CD1</a> status.</em></p>
<h3 id="706"><a href="lwg-defects.html#706">706</a>. <code>make_pair()</code> should behave as <code>make_tuple()</code> wrt. <code>reference_wrapper()</code></h3>
<p><b>Section:</b> 22.3 <a href="https://wg21.link/pairs">[pairs]</a> <b>Status:</b> <a href="lwg-active.html#CD1">CD1</a>
 <b>Submitter:</b> Thorsten Ottosen <b>Opened:</b> 2007-07-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#pairs">issues</a> in [pairs].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#CD1">CD1</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The current draft has <code>make_pair()</code> in 22.3 <a href="https://wg21.link/pairs">[pairs]</a>/16
and <code>make_tuple()</code> in 22.4.5 <a href="https://wg21.link/tuple.creation">[tuple.creation]</a>.
<code>make_tuple()</code> detects the presence of
<code>reference_wrapper&lt;X&gt;</code> arguments and "unwraps" the reference in
such cases. <code>make_pair()</code> would OTOH create a
<code>reference_wrapper&lt;X&gt;</code> member. I suggest that the two
functions are made to behave similar in this respect to minimize
confusion.
</p>


<p id="res-706"><b>Proposed resolution:</b></p>
<p>
In 22.2 <a href="https://wg21.link/utility">[utility]</a> change the synopsis for make_pair() to read
</p>

<blockquote><pre>
template &lt;class T1, class T2&gt;
  pair&lt;<del>typename decay&lt;T1&gt;::type</del> <ins>V1</ins>, <del>typename decay&lt;T2&gt;::type</del> <ins>V2</ins>&gt; make_pair(T1&amp;&amp;, T2&amp;&amp;);
</pre></blockquote>

<p>
In 22.3 <a href="https://wg21.link/pairs">[pairs]</a>/16 change the declaration to match the above synopsis.
Then change the 22.3 <a href="https://wg21.link/pairs">[pairs]</a>/17 to:
</p>

<blockquote>
<p>
<i>Returns:</i> <code>pair&lt;<del>typename decay&lt;T1&gt;::type</del> <ins>V1</ins>,<del>typename decay&lt;T2&gt;::type</del> <ins>V2</ins>&gt;(forward&lt;T1&gt;(x),forward&lt;T2&gt;(y))</code> <ins>where <code>V1</code> and
<code>V2</code> are determined as follows: Let <code>Ui</code> be
<code>decay&lt;Ti&gt;::type</code> for each <code>Ti</code>. Then each
<code>Vi</code> is <code>X&amp;</code> if <code>Ui</code> equals
<code>reference_wrapper&lt;X&gt;</code>, otherwise <code>Vi</code> is
<code>Ui</code>.</ins>
</p>
</blockquote>






</body>
</html>
