Created on 2020-05-08.00:00:00 last changed 21 months ago
Proposed resolution:
This wording is relative to N4861.
Modify [namespace.std], footnote 173, as indicated:
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.
Therefore an implementation may elect, under the as-if rule ([intro.execution]), to provide any customization point in the form of an instantiated function object ([function.objects]) 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 operator() must match those of the corresponding customization point's specification.
[ 2023-03-22 LWG 3441 was approved in Issaquah. Status changed: Open → Resolved. ]
[ Issaquah 2023-02-09; Jonathan adds note ]
This would be resolved by the new proposed resolution of LWG 3441.
[ 2020-10-02; status to Open ]
[ 2020-07-17; Priority set to 1 in telecon ]
Related to 3441.
Footnote 173 under [namespace.std]/7 reads (emphasis mine):
Any library customization point must be prepared to work adequately with any user-defined overload that meets the minimum requirements of this document. Therefore an implementation may elect, under the as-if rule ([intro.execution]), to provide any customization point in the form of an instantiated function object ([function.objects]) 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 operator() must match those of the corresponding customization point's specification.
This implementation suggestion doesn't seem to be satisfiable with the as-if rule.
In order to maintain as-if rule for qualified calls to std::swap, std::swap cannot perform ADL look-up like std::ranges::swap does.
But then we cannot maintain as-if rule for two-step calls to std::swap, since ADL is turned off when function objects are involved.
#include <iostream> namespace S { #ifdef CPO static constexpr auto swap = [](auto&, auto&) { std::cout << "std"; }; #else template<typename T> swap(T&, T&) { std::cout << "std"; } #endif } namespace N { struct X {}; void swap(X&, X&) { std::cout << "mine"; } } int main() { N::X a, b; S::swap(a, b); // (1) prints `std` in both cases using S::swap; swap(a, b); // (2) prints `std` with `-DCPO`, and `mine` without. }
We can try to satisfy the as-if rule for (2) by having std::swap perform ADL like std::ranges::swap, but then that would break (1) since qualified calls to std::swap would also ADL when it did not do so before.
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-03-22 12:28:35 | admin | set | messages: + msg13461 |
2023-03-22 12:28:35 | admin | set | status: open -> resolved |
2023-02-10 00:11:39 | admin | set | messages: + msg13321 |
2020-10-02 18:55:49 | admin | set | messages: + msg11501 |
2020-10-02 18:55:49 | admin | set | status: new -> open |
2020-07-17 22:37:26 | admin | set | messages: + msg11378 |
2020-05-09 20:16:07 | admin | set | messages: + msg11283 |
2020-05-08 00:00:00 | admin | create |