<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2433: uninitialized_copy()/etc. should tolerate overloaded operator&amp;</title>
<meta property="og:title" content="Issue 2433: uninitialized_copy()/etc. should tolerate overloaded operator&amp;">
<meta property="og:description" content="C++ library issue. Status: C++17">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2433.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="2433"><a href="lwg-defects.html#2433">2433</a>. <code>uninitialized_copy()</code>/etc. should tolerate overloaded <code>operator&amp;</code></h3>
<p><b>Section:</b> 26.11 <a href="https://wg21.link/specialized.algorithms">[specialized.algorithms]</a> <b>Status:</b> <a href="lwg-active.html#C++17">C++17</a>
 <b>Submitter:</b> Stephan T. Lavavej <b>Opened:</b> 2014-10-01 <b>Last modified:</b> 2017-07-30</p>
<p><b>Priority: </b>0
</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++17">C++17</a> status.</p>
<p><b>Discussion:</b></p>
<p>
This restriction isn't necessary anymore. In fact, this is the section that defines <code>addressof()</code>.
</p>
<p>
(Editorial note: We can depict these algorithms as calling <code>addressof()</code> instead of <code>std::addressof()</code> 
thanks to 16.4.2.2 <a href="https://wg21.link/contents">[contents]</a>/3 "Whenever a name <code>x</code> defined in the standard library is mentioned, the name 
<code>x</code> is assumed to be fully qualified as <code>::std::x</code>, unless explicitly described otherwise.")
</p>

<p><i>[Urbana 2014-11-07: Move to Ready]</i></p>




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

<ol>
<li><p>Change 26.11 <a href="https://wg21.link/specialized.algorithms">[specialized.algorithms]</a> p1 as depicted:</p>

<blockquote>
<p>
-1- <del>All the iterators that are used as formal template parameters in the following algorithms are required to
have their <code>operator*</code> return an object for which <code>operator&amp;</code> is defined and returns a pointer to 
<code>T</code>.</del> In the algorithm <code>uninitialized_copy</code>, the formal template parameter <code>InputIterator</code> 
is required to satisfy the requirements of an input iterator (24.2.3). In all of the following algorithms, the formal 
template parameter <code>ForwardIterator</code> is required to satisfy the requirements of a forward iterator (24.2.5), 
and is required to have the property that no exceptions are thrown from increment, assignment, comparison, or indirection
through valid iterators. In the following algorithms, if an exception is thrown there are no effects.
</p>
</blockquote>
</li>

<li><p>Change 26.11.5 <a href="https://wg21.link/uninitialized.copy">[uninitialized.copy]</a> p1 as depicted:</p>
<blockquote>
<p>
-1- <i>Effects</i>:
</p>
<blockquote>
<pre>
for (; first != last; ++result, ++first)
  ::new (static_cast&lt;void*&gt;(<ins>addressof(</ins><del>&amp;</del>*result<ins>)</ins>))
    typename iterator_traits&lt;ForwardIterator&gt;::value_type(*first);
</pre>
</blockquote>
</blockquote>
</li>

<li><p>Change 26.11.5 <a href="https://wg21.link/uninitialized.copy">[uninitialized.copy]</a> p3 as depicted:</p>
<blockquote>
<p>
-3- <i>Effects</i>:
</p>
<blockquote>
<pre>
for (; n &gt; 0; ++result, ++first, --n) {
  ::new (static_cast&lt;void*&gt;(<ins>addressof(</ins><del>&amp;</del>*result<ins>)</ins>))
    typename iterator_traits&lt;ForwardIterator&gt;::value_type(*first);
}
</pre>
</blockquote>
</blockquote>
</li>

<li><p>Change 26.11.7 <a href="https://wg21.link/uninitialized.fill">[uninitialized.fill]</a> p1 as depicted:</p>
<blockquote>
<p>
-1- <i>Effects</i>:
</p>
<blockquote>
<pre>
for (; first != last; ++first)
  ::new (static_cast&lt;void*&gt;(<ins>addressof(</ins><del>&amp;</del>*first<ins>)</ins>))
    typename iterator_traits&lt;ForwardIterator&gt;::value_type(x);
</pre>
</blockquote>
</blockquote>
</li>

<li><p>Change  [uninitialized.fill.n] p1 as depicted:</p>
<blockquote>
<p>
-1- <i>Effects</i>:
</p>
<blockquote>
<pre>
for (; n--; ++first)
  ::new (static_cast&lt;void*&gt;(<ins>addressof(</ins><del>&amp;</del>*first<ins>)</ins>))
    typename iterator_traits&lt;ForwardIterator&gt;::value_type(x);
return first;
</pre>
</blockquote>
</blockquote>
</li>
</ol>






</body>
</html>
