<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2177: Requirements on Copy&#47;MoveInsertable</title>
<meta property="og:title" content="Issue 2177: Requirements on Copy&#47;MoveInsertable">
<meta property="og:description" content="C++ library issue. Status: C++14">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2177.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++14">C++14</a> status.</em></p>
<h3 id="2177"><a href="lwg-defects.html#2177">2177</a>. Requirements on <code>Copy&#47;MoveInsertable</code></h3>
<p><b>Section:</b> 23.2.2 <a href="https://wg21.link/container.requirements.general">[container.requirements.general]</a> <b>Status:</b> <a href="lwg-active.html#C++14">C++14</a>
 <b>Submitter:</b> Lo&iuml;c Joly <b>Opened:</b> 2012-08-10 <b>Last modified:</b> 2017-09-07</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View other</b> <a href="lwg-index-open.html#container.requirements.general">active issues</a> in [container.requirements.general].</p>
<p><b>View all other</b> <a href="lwg-index.html#container.requirements.general">issues</a> in [container.requirements.general].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++14">C++14</a> status.</p>
<p><b>Discussion:</b></p>

<p>
See also discussion following <a href="http://listarchives.isocpp.org/cgi-bin/wg21/message?wg=lib&amp;msg=32883">c++std-lib-32883</a>
and <a href="http://listarchives.isocpp.org/cgi-bin/wg21/message?wg=lib&amp;msg=32897">c++std-lib-32897</a>.
<p/>
The requirements on <code>CopyInsertable</code> and <code>MoveInsertable</code> are either incomplete, or complete but hard to 
figure out.
<p/>
From e-mail <a href="http://listarchives.isocpp.org/cgi-bin/wg21/message?wg=lib&amp;msg=32897">c++std-lib-32897</a>:
<p/>
Pablo Halpern:
<p/>
I agree that we need semantic requirements for all of the <code>*Insertable</code> concepts analogous to the requirements 
we have on similar concepts.
<p/>
Howard Hinnant:
<p/>
I've come to believe that the standard is actually correct as written in this area. But it is <em>really</em> hard 
to read. I would have no objection whatsoever to clarifications to <code>CopyInsertable</code> as you suggest (such as the 
post-conditions on <code>v</code>). And I do agree with you that the correct approach to the clarifications is to 
confirm that <code>CopyInsertable</code> implies <code>MoveInsertable</code>.
</p>

<p><i>[2012, Portland: Move to Tentatively Ready]</i></p>

<p>
Move to Tentatively Ready by unanimous consent.
</p>

<p><i>[2013-04-20 Bristol]</i></p>




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

<ol>
<li><p>Edit 23.2.2 <a href="https://wg21.link/container.requirements.general">[container.requirements.general]</a> p13 as indicated:</p>

<blockquote><p>
-13- [&hellip;] Given a container type <code>X</code> having an <code>allocator_type</code> identical to <code>A</code> and 
a <code>value_type</code> identical to <code>T</code> and given an lvalue <code>m</code> of type <code>A</code>, a pointer <code>p</code> 
of type <code>T*</code>, an expression <code>v</code> of type (possibly <code>const</code>) <code>T</code>, and an rvalue <code>rv</code> 
of type <code>T</code>, the following terms are defined. If <code>X</code> is not allocator-aware, the terms below are
defined as if <code>A</code> were <code>std::allocator&lt;T&gt;</code> &mdash; no allocator object needs to be created and 
user specializations of <code>std::allocator&lt;T&gt;</code> are not instantiated:
</p>
<ul>
<li><p><code>T</code> is <em><code>DefaultInsertable</code> into <code>X</code></em> means that the following expression is 
well-formed:</p>
<blockquote><pre>
allocator_traits&lt;A&gt;::construct(m, p)<del>;</del>
</pre></blockquote>
</li>

<li><p>An element of <code>X</code> is <em>default-inserted</em> if it is initialized by evaluation of the expression</p>
<blockquote><pre>
allocator_traits&lt;A&gt;::construct(m, p)<del>;</del>
</pre></blockquote>
<p>
where <code>p</code> is the address of the uninitialized storage for the element allocated within <code>X</code>.
</p>
</li>

<li><p><code>T</code> is <em><code><del>Copy</del><ins>Move</ins>Insertable</code> into <code>X</code></em> means that 
the following expression is well-formed:</p>
<blockquote><pre>
allocator_traits&lt;A&gt;::construct(m, p, <ins>r</ins>v)<del>;</del>
</pre></blockquote>
<p>
<ins>and when evaluated the following postconditions hold: The value of <code>*p</code> is equivalent to the value of 
<code>rv</code> before the evaluation. [<i>Note</i>: <code>rv</code> remains a valid object. Its state is unspecified &mdash; 
<i>end note</i>]</ins>
</p>
</li>

<li><p><code>T</code> is <em><code><del>Move</del><ins>Copy</ins>Insertable</code> into <code>X</code></em> means 
that<ins>, in addition to satisfying the <code>MoveInsertable</code> requirements,</ins> the following expression is 
well-formed:</p>
<blockquote><pre>
allocator_traits&lt;A&gt;::construct(m, p, <del>r</del>v)<del>;</del>
</pre></blockquote>
<p>
<ins>and when evaluated the following postconditions hold: The value of <code>v</code> is unchanged and is equivalent 
to <code>*p</code>.</ins>
</p>
</li>

<li><p><code>T</code> is <em><code>EmplaceConstructible</code> into <code>X</code> from <code>args</code></em>, for zero or more arguments 
<code>args</code>, means that the following expression is well-formed:</p>
<blockquote><pre>
allocator_traits&lt;A&gt;::construct(m, p, args)<del>;</del>
</pre></blockquote>
</li>

<li><p><code>T</code> is <em><code>Erasable</code> from <code>X</code></em> means that the following expression is well-formed:</p>
<blockquote><pre>
allocator_traits&lt;A&gt;::destroy(m, p)<del>;</del>
</pre></blockquote>
</li>

</ul>
<p>
[<i>Note</i>: A container calls <code>allocator_traits&lt;A&gt;::construct(m, p, args)</code> to construct an element 
at <code>p</code> using <code>args</code>. The default construct in <code>std::allocator</code> will call 
<code>::new((void*)p) T(args)</code>, but specialized allocators may choose a different definition. &mdash; <i>end note</i>]
</p>
</blockquote>
</li>

</ol>






</body>
</html>
