<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 866: Qualification of placement new-expressions</title>
<meta property="og:title" content="Issue 866: Qualification of placement new-expressions">
<meta property="og:description" content="C++ library issue. Status: C++11">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue866.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++11">C++11</a> status.</em></p>
<h3 id="866"><a href="lwg-defects.html#866">866</a>. Qualification of placement new-expressions</h3>
<p><b>Section:</b> 26.11 <a href="https://wg21.link/specialized.algorithms">[specialized.algorithms]</a>, 20.3.2.2.7 <a href="https://wg21.link/util.smartptr.shared.create">[util.smartptr.shared.create]</a> <b>Status:</b> <a href="lwg-active.html#C++11">C++11</a>
 <b>Submitter:</b> Alberto Ganesh Barbati <b>Opened:</b> 2008-07-14 <b>Last modified:</b> 2016-01-28</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View other</b> <a href="lwg-index-open.html#specialized.algorithms">active issues</a> in [specialized.algorithms].</p>
<p><b>View all other</b> <a href="lwg-index.html#specialized.algorithms">issues</a> in [specialized.algorithms].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++11">C++11</a> status.</p>
<p><b>Discussion:</b></p>
<p>
LWG issue <a href="lwg-defects.html#402" title="wrong new expression in [some_]allocator::construct (Status: CD1)">402</a><sup><a href="https://cplusplus.github.io/LWG/issue402" title="Latest snapshot">(i)</a></sup> replaced "<code>new</code>" with "<code>::new</code>" in the placement
new-expression in 20.2.10.2 <a href="https://wg21.link/allocator.members">[allocator.members]</a>. I believe the rationale
given in <a href="lwg-defects.html#402" title="wrong new expression in [some_]allocator::construct (Status: CD1)">402</a><sup><a href="https://cplusplus.github.io/LWG/issue402" title="Latest snapshot">(i)</a></sup> applies also to the following other contexts:
</p>
<ul>
<li>
<p>
in 26.11 <a href="https://wg21.link/specialized.algorithms">[specialized.algorithms]</a>, all four algorithms <code>unitialized_copy</code>,
<code>unitialized_copy_n</code>, <code>unitialized_fill</code> and <code>unitialized_fill_n</code> use
the unqualified placement new-expression in some variation of the form:
</p>
<blockquote><pre>
new  (static_cast&lt;void*&gt;(&amp;*result)) typename  iterator_traits&lt;ForwardIterator&gt;::value_type(*first);
</pre></blockquote>
</li>
<li>
<p>
in 20.3.2.2.7 <a href="https://wg21.link/util.smartptr.shared.create">[util.smartptr.shared.create]</a> there is a reference to the unqualified placement new-expression:
</p>
<blockquote><pre>
new  (pv)  T(std::forward&lt;Args&gt;(args)...),
</pre></blockquote>
</li>
</ul>
<p>
I suggest to add qualification in all those places. As far as I know,
these are all the remaining places in the whole library that explicitly
use a placement new-expression. Should other uses come out, they should
be qualified as well.
</p>
<p>
As an aside, a qualified placement new-expression does not need
additional requirements to be compiled in a constrained context. By
adding qualification, the <code>HasPlacementNew</code> concept introduced recently in
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2677.pdf">N2677 (Foundational Concepts)</a>
would no longer be needed by library and
should therefore be removed.
</p>

<p><i>[
San Francisco:
]</i></p>


<blockquote><p>
Detlef: If we move this to Ready, it's likely that we'll forget about
the side comment about the <code>HasPlacementNew</code> concept.
</p></blockquote>

<p><i>[
post San Francisco:
]</i></p>


<blockquote><p>
Daniel:  <code>HasPlacementNew</code> has been removed from
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2774.pdf">N2774 (Foundational Concepts)</a>.
</p></blockquote>



<p id="res-866"><b>Proposed resolution:</b></p>
<p>
Replace "<code>new</code>" with "<code>::new</code>" in:
</p>
<ul>
<li>
26.11.5 <a href="https://wg21.link/uninitialized.copy">[uninitialized.copy]</a>, paragraphs 1 and 3
</li>
<li>
26.11.7 <a href="https://wg21.link/uninitialized.fill">[uninitialized.fill]</a>  paragraph 1
</li>
<li>
 [uninitialized.fill.n] paragraph 1
</li>
<li>
20.3.2.2.7 <a href="https://wg21.link/util.smartptr.shared.create">[util.smartptr.shared.create]</a> once in paragraph 1 and twice in paragraph 2.
</li>
</ul>






</body>
</html>
