<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3442: Unsatisfiable suggested implementation of customization points</title>
<meta property="og:title" content="Issue 3442: Unsatisfiable suggested implementation of customization points">
<meta property="og:description" content="C++ library issue. Status: Resolved">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3442.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#Resolved">Resolved</a> status.</em></p>
<h3 id="3442"><a href="lwg-defects.html#3442">3442</a>. Unsatisfiable suggested implementation of customization points</h3>
<p><b>Section:</b> 16.4.5.2.1 <a href="https://wg21.link/namespace.std">[namespace.std]</a> <b>Status:</b> <a href="lwg-active.html#Resolved">Resolved</a>
 <b>Submitter:</b> Michael Park <b>Opened:</b> 2020-05-08 <b>Last modified:</b> 2023-03-22</p>
<p><b>Priority: </b>1
</p>
<p><b>View other</b> <a href="lwg-index-open.html#namespace.std">active issues</a> in [namespace.std].</p>
<p><b>View all other</b> <a href="lwg-index.html#namespace.std">issues</a> in [namespace.std].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#Resolved">Resolved</a> status.</p>
<p><b>Discussion:</b></p>
<p>
Footnote 173 under [namespace.std]/7 reads (emphasis mine):
</p>
<blockquote style="border-left: 3px solid #ccc;padding-left: 15px;">
<p>
Any library customization point must be prepared to work adequately with any user-defined 
overload that meets the minimum requirements of this document. <b>Therefore an implementation 
may elect, under the as-if rule (6.10.1 <a href="https://wg21.link/intro.execution">[intro.execution]</a>), to provide any customization 
point in the form of an instantiated function object (22.10 <a href="https://wg21.link/function.objects">[function.objects]</a>) even 
though the customization point's specification is in the form of a function template.</b> 
The template parameters of each such function object and the function parameters and return 
type of the object's <code>operator()</code> must match those of the corresponding customization 
point's specification.
</p>
</blockquote>
<p>
This implementation suggestion doesn't seem to be satisfiable with the as-if rule.
</p>
<ol>
<li><p>In order to maintain as-if rule for qualified calls to <code>std::swap</code>, <code>std::swap</code> 
cannot perform ADL look-up like <code>std::ranges::swap</code> does.</p></li>
<li><p>But then we cannot maintain as-if rule for two-step calls to <code>std::swap</code>, since ADL 
is turned off when function objects are involved.</p>
<blockquote><pre>
#include &lt;iostream&gt;

namespace S {
#ifdef CPO
  static constexpr auto swap = [](auto&amp;, auto&amp;) { std::cout &lt;&lt; "std"; };
#else
  template&lt;typename T&gt; swap(T&amp;, T&amp;) { std::cout &lt;&lt; "std"; }
#endif
}

namespace N {
  struct X {};
  void swap(X&amp;, X&amp;) { std::cout &lt;&lt; "mine"; }
}

int main() {
  N::X a, b;
  S::swap(a, b);  // (1) prints <code class='backtick'>std</code> in both cases
  using S::swap;
  swap(a, b);     // (2) prints <code class='backtick'>std</code> with <code class='backtick'>-DCPO</code>, and <code class='backtick'>mine</code> without.
}
</pre></blockquote>
</li>
<li><p>We can try to satisfy the as-if rule for (2) by having <code>std::swap</code> perform ADL like 
<code>std::ranges::swap</code>, but then that would break (1) since qualified calls to <code>std::swap</code> 
would also ADL when it did not do so before.</p></li>
</ol>

<p><i>[2020-07-17; Priority set to 1 in telecon]</i></p>

<p>Related to <a href="lwg-defects.html#3441" title="Misleading note about calls to customization points (Status: C++23)">3441</a><sup><a href="https://cplusplus.github.io/LWG/issue3441" title="Latest snapshot">(i)</a></sup>.</p>

<p><i>[2020-10-02; status to Open]</i></p>


<p><i>[Issaquah 2023-02-09; Jonathan adds note]</i></p>

<p>
This would be resolved by the new proposed resolution of LWG
<a href="lwg-defects.html#3441" title="Misleading note about calls to customization points (Status: C++23)">3441</a><sup><a href="https://cplusplus.github.io/LWG/issue3441" title="Latest snapshot">(i)</a></sup>.
</p>

<p><i>[2023-03-22 LWG 3441 was approved in Issaquah. Status changed: Open &rarr; Resolved.]</i></p>



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

<ol>
<li><p>Modify 16.4.5.2.1 <a href="https://wg21.link/namespace.std">[namespace.std]</a>, footnote 173, as indicated:</p>

<blockquote>
<p>
footnote 173) Any library customization point must be prepared to work adequately with any user-defined overload 
that meets the minimum requirements of this document. <del>Therefore an implementation may elect, under the 
as-if rule (6.10.1 <a href="https://wg21.link/intro.execution">[intro.execution]</a>), to provide any customization point in the form of an 
instantiated function object (22.10 <a href="https://wg21.link/function.objects">[function.objects]</a>) even though the customization point's 
specification is in the form of a function template. The template parameters of each such function 
object and the function parameters and return type of the object's <code>operator()</code> must match those 
of the corresponding customization point's specification.</del>
</p>
</blockquote>
</li>

</ol>




</body>
</html>
