<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2476: scoped_allocator_adaptor is not assignable</title>
<meta property="og:title" content="Issue 2476: scoped_allocator_adaptor is not assignable">
<meta property="og:description" content="C++ library issue. Status: C++17">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2476.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++17">C++17</a> status.</em></p>
<h3 id="2476"><a href="lwg-defects.html#2476">2476</a>. <code>scoped_allocator_adaptor</code> is not assignable</h3>
<p><b>Section:</b> 20.6.1 <a href="https://wg21.link/allocator.adaptor.syn">[allocator.adaptor.syn]</a> <b>Status:</b> <a href="lwg-active.html#C++17">C++17</a>
 <b>Submitter:</b> Jonathan Wakely <b>Opened:</b> 2015-03-02 <b>Last modified:</b> 2017-07-30</p>
<p><b>Priority: </b>0
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++17">C++17</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The class definition in 20.6.1 <a href="https://wg21.link/allocator.adaptor.syn">[allocator.adaptor.syn]</a> declares a move
constructor, which means that the copy assignment operator is defined
as deleted, and no move assignment operator is declared.
<p/>
This means a <code>scoped_allocator_adaptor</code> is not assignable, and a
container using <code>scoped_allocator_adaptor&lt;A...&gt;</code> may not be
<code>CopyAssignable</code> or <code>MoveAssignable</code> (depending on the
<code>propagate_on_container_xxxx_assignment</code> traits of the outer and inner
allocator types).
</p>

<p><i>[2015-04-03 Howard comments]</i></p>

<p>
If the contained allocators are not assignable, I think we need the ability of <code>= default</code> to automagically become 
<code>= delete</code>. My concern is that <code>is_copy_assignable&lt;scoped_allocator_adaptor&lt;CustomAllocator&gt;&gt;::value</code> 
get the right answer for both cases:
</p>
<ol>
<li><p><code>is_copy_assignable&lt;CustomAllocator&gt;::value</code> is <code>true</code>.</p></li>
<li><p><code>is_copy_assignable&lt;CustomAllocator&gt;::value</code> is <code>false</code>.</p></li>
</ol>
<p>
If we allow the vendor to declare and provide the copy assignment operator, the chance of getting #2 correct goes to zero.
</p>

<p>
<strong>Previous resolution [SUPERSEDED]:</strong>
</p>
<blockquote class="note">
<p>This wording is relative to N4296.</p>

<ol>
<li>
<p>Add to the synopsis in 20.6.1 <a href="https://wg21.link/allocator.adaptor.syn">[allocator.adaptor.syn]</a>/1 [<i>Editorial remark</i>: The proposed wording
does not explicitly specify the semantics of the added copy/move assignment operators, based on 
16.3.3.5 <a href="https://wg21.link/functions.within.classes">[functions.within.classes]</a> p1, which says:
<p/>
"For the sake of exposition, Clauses 18 through 30 and Annex D do not describe copy/move constructors,
assignment operators, or (non-virtual) destructors with the same apparent semantics as those that can be
generated by default (12.1, 12.4, 12.8)."
<p/>
&mdash; <i>end remark</i>]:
</p>
<blockquote>
<pre>
[&hellip;]
template &lt;class OuterA2&gt;
  scoped_allocator_adaptor(
    scoped_allocator_adaptor&lt;OuterA2, InnerAllocs...&gt;&amp;&amp; other) noexcept;
<ins>
scoped_allocator_adaptor&amp; operator=(const scoped_allocator_adaptor&amp;);
scoped_allocator_adaptor&amp; operator=(scoped_allocator_adaptor&amp;&amp;);
</ins>
~scoped_allocator_adaptor();
[&hellip;]
</pre>
</blockquote>
</li>
</ol>
</blockquote>

<p><i>[2015-05, Lenexa]</i></p>

<p>
Move to Immediate.
</p>


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

<ol>
<li>
<p>Add to the synopsis in 20.6.1 <a href="https://wg21.link/allocator.adaptor.syn">[allocator.adaptor.syn]</a>/1:
</p>
<blockquote>
<pre>
[&hellip;]
template &lt;class OuterA2&gt;
  scoped_allocator_adaptor(
    scoped_allocator_adaptor&lt;OuterA2, InnerAllocs...&gt;&amp;&amp; other) noexcept;
<ins>
scoped_allocator_adaptor&amp; operator=(const scoped_allocator_adaptor&amp;) = default;
scoped_allocator_adaptor&amp; operator=(scoped_allocator_adaptor&amp;&amp;) = default;
</ins>
~scoped_allocator_adaptor();
[&hellip;]
</pre>
</blockquote>
</li>
</ol>





</body>
</html>
