<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3017: list splice functions should use addressof</title>
<meta property="og:title" content="Issue 3017: list splice functions should use addressof">
<meta property="og:description" content="C++ library issue. Status: C++20">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3017.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++20">C++20</a> status.</em></p>
<h3 id="3017"><a href="lwg-defects.html#3017">3017</a>. <code>list splice</code> functions should use <code>addressof</code></h3>
<p><b>Section:</b> 23.3.7.6 <a href="https://wg21.link/forward.list.ops">[forward.list.ops]</a>, 23.3.11.5 <a href="https://wg21.link/list.ops">[list.ops]</a> <b>Status:</b> <a href="lwg-active.html#C++20">C++20</a>
 <b>Submitter:</b> Jonathan Wakely <b>Opened:</b> 2017-09-05 <b>Last modified:</b> 2023-02-07</p>
<p><b>Priority: </b>0
</p>
<p><b>View all other</b> <a href="lwg-index.html#forward.list.ops">issues</a> in [forward.list.ops].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++20">C++20</a> status.</p>
<p><b>Discussion:</b></p>
<p>
 [forwardlist.ops] p1 and 23.3.11.5 <a href="https://wg21.link/list.ops">[list.ops]</a> p3 say <code>&amp;x != this</code>, but should use
<code>addressof</code>. We really need front matter saying that when the library says <code>&amp;x</code> it means 
<code>std::addressof(x)</code>.
</p>

<p><i>[
2017-11-03 Moved to Tentatively Ready after 9 positive votes for P0 on c++std-lib.
]</i></p>

<p><i>[2018-3-17 Adopted in Jacksonville]</i></p>



<p id="res-3017"><b>Proposed resolution:</b></p>
<p>This wording is relative to <a href="https://wg21.link/n4687">N4687</a>.</p>

<ol>
<li><p>Edit  [forwardlist.ops] p1 as indicated:</p>
<blockquote>
<pre>
void splice_after(const_iterator position, forward_list&amp; x);
void splice_after(const_iterator position, forward_list&amp;&amp; x);
</pre>
<blockquote>
<p>
-1- <i>Requires:</i> <code>position</code> is <code>before_begin()</code> or is a dereferenceable iterator in the range <code>[begin(), 
end())</code>. <code>get_allocator() == x.get_allocator()</code>. <code><del>&amp;</del><ins>addressof(</ins>x<ins>)</ins> != this</code>.
</p>
</blockquote>
</blockquote>
</li>

<li><p>Edit 23.3.11.5 <a href="https://wg21.link/list.ops">[list.ops]</a> p3 as indicated:</p>
<blockquote>
<pre>
void splice(const_iterator position, list&amp; x);
void splice(const_iterator position, list&amp;&amp; x);
</pre>
<blockquote>
<p>
-3- <i>Requires:</i> <code><del>&amp;</del><ins>addressof(</ins>x<ins>)</ins> != this</code>.
</p>
</blockquote>
</blockquote>
</li>

<li><p>Edit 23.3.11.5 <a href="https://wg21.link/list.ops">[list.ops]</a> p3 as indicated:</p>
<blockquote>
<pre>
template &lt;class Compare&gt; void merge(list&amp; x, Compare comp);
template &lt;class Compare&gt; void merge(list&amp;&amp; x, Compare comp);
</pre>
<blockquote>
<p>
-22- <i>Requires:</i> <code>comp</code> shall define a strict weak ordering (26.8 <a href="https://wg21.link/alg.sorting">[alg.sorting]</a>), and both the list 
and the argument list shall be sorted according to this ordering.
<p/>
-23- <i>Effects:</i> If <code>(<del>&amp;</del><ins>addressof(</ins>x<ins>)</ins> == this)</code> does nothing; 
otherwise, merges the two sorted ranges <code>[begin(), end())</code> and <code>[x.begin(), x.end())</code>. The result 
is a range in which the elements will be sorted in non-decreasing order according to the ordering defined by 
<code>comp</code>; that is, for every iterator <code>i</code>, in the range other than the first, the condition 
<code>comp(*i, *(i - 1))</code> will be <code>false</code>. Pointers and references to the moved elements of <code>x</code> 
now refer to those same elements but as members of <code>*this</code>. Iterators referring to the moved elements 
will continue to refer to their elements, but they now behave as iterators into <code>*this</code>, not into <code>x</code>.
<p/>
-24- <i>Remarks:</i> Stable (16.4.6.8 <a href="https://wg21.link/algorithm.stable">[algorithm.stable]</a>). If 
<code>(<del>&amp;</del><ins>addressof(</ins>x<ins>)</ins> != this)</code> the range <code>[x.begin(), x.end())</code> is 
empty after the merge. No elements are copied by this operation. The behavior is undefined if <code>get_allocator() !=
x.get_allocator()</code>.
<p/>
-25- <i>Complexity:</i> At most <code>size() + x.size() - 1</code> applications of <code>comp</code> if 
<code>(<del>&amp;</del><ins>addressof(</ins>x<ins>)</ins> != this)</code>; otherwise, no applications of <code>comp</code> are 
performed. If an exception is thrown other than by a comparison there are no effects.
</p>
</blockquote>
</blockquote>
</li>
</ol>





</body>
</html>
