<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 756: Container adaptors push</title>
<meta property="og:title" content="Issue 756: Container adaptors push">
<meta property="og:description" content="C++ library issue. Status: Resolved">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue756.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="756"><a href="lwg-defects.html#756">756</a>. Container adaptors push</h3>
<p><b>Section:</b> 23.6 <a href="https://wg21.link/container.adaptors">[container.adaptors]</a> <b>Status:</b> <a href="lwg-active.html#Resolved">Resolved</a>
 <b>Submitter:</b> Paolo Carlini <b>Opened:</b> 2007-10-31 <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#container.adaptors">issues</a> in [container.adaptors].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#Resolved">Resolved</a> status.</p>
<p><b>Discussion:</b></p>
<p>
After n2369 we have a single <code>push_back</code> overload in the sequence containers,
of the "emplace" type. At variance with that, still in n2461, we have
two separate overloads, the C++03 one + one taking an rvalue reference
in the container adaptors. Therefore, simply from a consistency point of
view, I was wondering whether the container adaptors should be aligned
with the specifications of the sequence container themselves: thus have
a single <code>push</code> along the lines:
</p>

<blockquote><pre>
template&lt;typename... _Args&gt;
void
push(_Args&amp;&amp;... __args)
  { c.push_back(std::forward&lt;_Args&gt;(__args)...); }
</pre></blockquote>

<p><i>[
Related to <a href="lwg-defects.html#767" title="Forwarding and backward compatibility (Status: Resolved)">767</a><sup><a href="https://cplusplus.github.io/LWG/issue767" title="Latest snapshot">(i)</a></sup>
]</i></p>



<p id="res-756"><b>Proposed resolution:</b></p>
<p>
Change 23.6.3.1 <a href="https://wg21.link/queue.defn">[queue.defn]</a>:
</p>

<blockquote><pre>
<del>void push(const value_type&amp; x) { c.push_back(x); }</del>
<del>void push(value_type&amp;&amp; x) { c.push_back(std::move(x)); }</del>
<ins>template&lt;class... Args&gt; void push(Args&amp;&amp;... args) { c.push_back(std::forward&lt;Args&gt;(args)...); }</ins>
</pre></blockquote>

<p>
Change 23.6.4 <a href="https://wg21.link/priority.queue">[priority.queue]</a>:
</p>

<blockquote><pre>
<del>void push(const value_type&amp; x) { c.push_back(x); }</del>
<del>void push(value_type&amp;&amp; x) { c.push_back(std::move(x)); }</del>
<ins>template&lt;class... Args&gt; void push(Args&amp;&amp;... args) { c.push_back(std::forward&lt;Args&gt;(args)...); }</ins>
</pre></blockquote>

<p>
Change 23.6.4.4 <a href="https://wg21.link/priqueue.members">[priqueue.members]</a>:
</p>

<blockquote>
<pre>
<del>void push(const value_type&amp; x);</del>
</pre>
<blockquote>
<p>
<del><i>Effects:</i></del>
</p>
<blockquote><pre>
<del>c.push_back(x);</del>
<del>push_heap(c.begin(), c.end(), comp);</del>
</pre></blockquote>
</blockquote>

<pre>
<ins>template&lt;class... Args&gt;</ins> void push(<del>value_type</del> <ins>Args</ins>&amp;&amp;<ins>...</ins> <del>x</del> <ins>args</ins>);
</pre>
<blockquote>
<p>
<i>Effects:</i>
</p>
<blockquote><pre>
c.push_back(std::<del>move</del><ins>forward&lt;Args&gt;</ins>(<del>x</del> <ins>args</ins>)<ins>...</ins>);
push_heap(c.begin(), c.end(), comp);
</pre></blockquote>
</blockquote>
</blockquote>

<p>
Change 23.6.6.2 <a href="https://wg21.link/stack.defn">[stack.defn]</a>:
</p>

<blockquote><pre>
<del>void push(const value_type&amp; x) { c.push_back(x); }</del>
<del>void push(value_type&amp;&amp; x) { c.push_back(std::move(x)); }</del>
<ins>template&lt;class... Args&gt; void push(Args&amp;&amp;... args) { c.push_back(std::forward&lt;Args&gt;(args)...); }</ins>
</pre></blockquote>



<p><b>Rationale:</b></p>
<p>
Addressed by
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2680.pdf">N2680 Proposed Wording for Placement Insert (Revision 1)</a>.
</p>





</body>
</html>
