<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3413: [fund.ts.v3] propagate_const's swap's noexcept specification needs to 
be constrained and use a trait</title>
<meta property="og:title" content="Issue 3413: [fund.ts.v3] propagate_const's swap's noexcept specification needs to 
be constrained and use a trait">
<meta property="og:description" content="C++ library issue. Status: C++23">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3413.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++23">C++23</a> status.</em></p>
<h3 id="3413"><a href="lwg-defects.html#3413">3413</a>. [fund.ts.v3] <code>propagate_const</code>'s <code>swap</code>'s <code>noexcept</code> specification needs to 
be constrained and use a trait</h3>
<p><b>Section:</b> 6.1.2.8 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#propagate_const.modifiers">[fund.ts.v3::propagate_const.modifiers]</a>, 6.1.2.10 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#propagate_const.algorithms">[fund.ts.v3::propagate_const.algorithms]</a> <b>Status:</b> <a href="lwg-active.html#C++23">C++23</a>
 <b>Submitter:</b> Thomas K&ouml;ppe <b>Opened:</b> 2020-02-29 <b>Last modified:</b> 2023-11-22</p>
<p><b>Priority: </b>0
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++23">C++23</a> status.</p>
<p><b>Discussion:</b></p>
<p><b>Addresses: fund.ts.v3</b></p>
<p>
In the Fundamentals TS, the <code>noexcept</code> specifications of both the member and non-member <code>swap</code> 
functions for <code>propagate_const</code> are using the old, ill-formed pattern of attempting to use 
"<code>noexcept(swap(...))</code>" as the boolean predicate. According to LWG <a href="lwg-defects.html#2456" title="Incorrect exception specifications for 'swap' throughout library (Status: Resolved)">2456</a><sup><a href="https://cplusplus.github.io/LWG/issue2456" title="Latest snapshot">(i)</a></sup>, this is 
ill-formed, and a resolution such as in <a href="https://wg21.link/p0185r1">P0185R1</a> is required.
</p>

<strong>Previous resolution [SUPERSEDED]:</strong>
<blockquote class="note">
<p>
This wording is relative to <a href="https://wg21.link/n4840">N4840</a>.
</p>

<ol>
<li><p>Modify 6.1.1 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#propagate_const.syn">[fund.ts.v3::propagate_const.syn]</a>, header <code>&lt;experimental/propagate_const&gt;</code> synopsis, 
as indicated:</p>

<blockquote>
<pre>
<i>// 6.1.2.10 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#propagate_const.algorithms">[fund.ts.v3::propagate_const.algorithms]</a>, propagate_const specialized algorithms</i>
template &lt;class T&gt;
  constexpr void swap(propagate_const&lt;T&gt;&amp; pt, propagate_const&lt;T&gt;&amp; pt2) noexcept(<del><i>see below</i></del><ins>is_nothrow_swappable_v&lt;T&gt;</ins>);
</pre>
</blockquote>
</li>

<li><p>Modify 6.1.2.1 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#propagate_const.overview">[fund.ts.v3::propagate_const.overview]</a>, class template <code>propagate_const</code> synopsis, 
as indicated:</p>

<blockquote>
<pre>
<i>// 6.1.2.8 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#propagate_const.modifiers">[fund.ts.v3::propagate_const.modifiers]</a>, propagate_const modifiers</i>
constexpr void swap(propagate_const&amp; pt) noexcept(<del><i>see below</i></del><ins>is_nothrow_swappable_v&lt;T&gt;</ins>);
</pre>
</blockquote>
</li>

<li><p>Modify 6.1.2.8 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#propagate_const.modifiers">[fund.ts.v3::propagate_const.modifiers]</a> as indicated:</p>

<blockquote>
<pre>
constexpr void swap(propagate_const&amp; pt) noexcept(<del><i>see below</i></del><ins>is_nothrow_swappable_v&lt;T&gt;</ins>);
</pre>
<blockquote>
<p>
<del>-2- The constant-expression in the exception-specification is <code>noexcept(swap(t_, pt.t_))</code>.</del>
<p/>
-3- <i>Effects:</i> <code>swap(t_, pt.t_)</code>. 
</p>
</blockquote>
</blockquote>
</li>

<li><p>Modify 6.1.2.10 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#propagate_const.algorithms">[fund.ts.v3::propagate_const.algorithms]</a> as indicated:</p>

<blockquote>
<pre>
template &lt;class T&gt;
  constexpr void swap(propagate_const&lt;T&gt;&amp; pt1, propagate_const&lt;T&gt;&amp; pt2) noexcept(<del><i>see below</i></del><ins>is_nothrow_swappable_v&lt;T&gt;</ins>);
</pre>
<blockquote>
<p>
<del>-2- The constant-expression in the exception-specification is <code>noexcept(pt1.swap(pt2))</code>.</del>
<p/>
-3- <i>Effects:</i> <code>pt1.swap(pt2)</code>. 
</p>
</blockquote>
</blockquote>
</li>
</ol>
</blockquote>

<p><i>[2020-03-30; Reflector discussion]</i></p>

<p>
This issue has very much overlap with LWG <a href="lwg-defects.html#2561" title="[fund.ts.v2] Incorrect exception specifications for 'swap' in C++ Extensions for Library Fundamentals (Status: Resolved)">2561</a><sup><a href="https://cplusplus.github.io/LWG/issue2561" title="Latest snapshot">(i)</a></sup>, especially now that the library fundamentals has been rebased
to C++20 the there reported problem for the corresponding <code>swap</code> problem for <code>optional</code> is now moot. During the
reflector discussion of this issue here it was also observed that the free <code>swap</code> template for <code>propagate_const</code>
needs to be constrained. This has been done below in the revised wording which also attempts to use a similar style as
the IS.
</p>

<strong>Previous resolution [SUPERSEDED]:</strong>
<blockquote class="note">
<p>
This wording is relative to <a href="https://wg21.link/n4840">N4840</a>.
</p>

<ol>

<li><p>Modify 6.1.2.1 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#propagate_const.overview">[fund.ts.v3::propagate_const.overview]</a>, class template <code>propagate_const</code> synopsis, 
as indicated:</p>

<blockquote>
<pre>
<i>// 6.1.2.8 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#propagate_const.modifiers">[fund.ts.v3::propagate_const.modifiers]</a>, propagate_const modifiers</i>
constexpr void swap(propagate_const&amp; pt) noexcept(<del><i>see below</i></del><ins>is_nothrow_swappable_v&lt;T&gt;</ins>);
</pre>
</blockquote>
</li>

<li><p>Modify 6.1.2.8 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#propagate_const.modifiers">[fund.ts.v3::propagate_const.modifiers]</a> as indicated:</p>

<blockquote>
<pre>
constexpr void swap(propagate_const&amp; pt) noexcept(<del><i>see below</i></del><ins>is_nothrow_swappable_v&lt;T&gt;</ins>);
</pre>
<blockquote>
<p>
<del>-2- The constant-expression in the exception-specification is <code>noexcept(swap(t_, pt.t_))</code>.</del>
<p/>
-3- <i>Effects:</i> <code>swap(t_, pt.t_)</code>. 
</p>
</blockquote>
</blockquote>
</li>

<li><p>Modify 6.1.2.10 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#propagate_const.algorithms">[fund.ts.v3::propagate_const.algorithms]</a> as indicated:</p>

<blockquote>
<pre>
template &lt;class T&gt;
  constexpr void swap(propagate_const&lt;T&gt;&amp; pt1, propagate_const&lt;T&gt;&amp; pt2) noexcept(<i>see below</i>);
</pre>
<blockquote>
<p>
<ins>-?- <i>Constraints:</i> <code>is_swappable_v&lt;T&gt;</code> is <code>true</code>.</ins>
<p/>
<del>-2- The constant-expression in the exception-specification is <code>noexcept(pt1.swap(pt2))</code>.</del>
<p/>
-3- <i>Effects:</i> <code>pt1.swap(pt2)</code>. 
<p/>
<ins>-?- <i>Remarks:</i> The expression inside <code>noexcept</code> is equivalent to:</ins>
<blockquote><pre>
<ins>noexcept(pt1.swap(pt2))</ins>
</pre></blockquote>
</p>
</blockquote>
</blockquote>
</li>
</ol></blockquote>

<p><i>[2020-04-06; Wording update upon reflector discussions]</i></p>


<p><i>[2020-05-03 Issue Prioritization]</i></p>
 
<p>
Status set to Tentatively Ready after five positive votes on the reflector.
</p>
<p><i>[2020-11-09 Approved In November virtual meeting. Status changed: Tentatively Ready &rarr; WP.]</i></p>



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

<ol>

<li><p>Modify 6.1.2.1 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#propagate_const.overview">[fund.ts.v3::propagate_const.overview]</a>, class template <code>propagate_const</code> synopsis, 
as indicated:</p>

<blockquote>
<pre>
<i>// 6.1.2.8 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#propagate_const.modifiers">[fund.ts.v3::propagate_const.modifiers]</a>, propagate_const modifiers</i>
constexpr void swap(propagate_const&amp; pt) noexcept(<del><i>see below</i></del><ins>is_nothrow_swappable_v&lt;T&gt;</ins>);
</pre>
</blockquote>
</li>

<li><p>Modify 6.1.2.8 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#propagate_const.modifiers">[fund.ts.v3::propagate_const.modifiers]</a> as indicated:</p>

<blockquote>
<pre>
constexpr void swap(propagate_const&amp; pt) noexcept(<del><i>see below</i></del><ins>is_nothrow_swappable_v&lt;T&gt;</ins>);
</pre>
<blockquote>
<p>
<ins>-?- <i>Preconditions:</i> Lvalues of type <code>T</code> are swappable (C++17 &sect;20.5.3.2).</ins>
<p/>
<del>-2- The constant-expression in the exception-specification is <code>noexcept(swap(t_, pt.t_))</code>.</del>
<p/>
-3- <i>Effects:</i> <code>swap(t_, pt.t_)</code>. 
</p>
</blockquote>
</blockquote>
</li>

<li><p>Modify 6.1.2.10 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#propagate_const.algorithms">[fund.ts.v3::propagate_const.algorithms]</a> as indicated:</p>

<blockquote>
<pre>
template &lt;class T&gt;
  constexpr void swap(propagate_const&lt;T&gt;&amp; pt1, propagate_const&lt;T&gt;&amp; pt2) noexcept(<i>see below</i>);
</pre>
<blockquote>
<p>
<ins>-?- <i>Constraints:</i> <code>is_swappable_v&lt;T&gt;</code> is <code>true</code>.</ins>
<p/>
<del>-2- The constant-expression in the exception-specification is <code>noexcept(pt1.swap(pt2))</code>.</del>
<p/>
-3- <i>Effects:</i> <ins>Equivalent to:</ins> <code>pt1.swap(pt2)</code>. 
<p/>
<ins>-?- <i>Remarks:</i> The expression inside <code>noexcept</code> is equivalent to:</ins>
<blockquote><pre>
<ins>noexcept(pt1.swap(pt2))</ins>
</pre></blockquote>
</p>
</blockquote>
</blockquote>
</li>
</ol>




</body>
</html>
