Section: 23.2 [utility], 23.4.2 [pairs.pair], 23.5 [tuple], 26.3.7 [array], 26.6.4 [queue], 26.6.5 [priority.queue], 26.6.6 [stack] Status: Resolved Submitter: Richard Smith Opened: 2014-11-14 Last modified: 2016-03-07
View all other issues in [utility].
View all issues with Resolved status.
We have this antipattern in various library classes:
void swap(priority_queue& q) noexcept( noexcept(swap(c, q.c)) && noexcept(swap(comp, q.comp)))
This doesn't work. The unqualified lookup for 'swap' finds the member named 'swap', and that suppresses ADL, so the exception specification is always ill-formed because you can't call the member 'swap' with two arguments.Relevant history on the core language side: This used to be ill-formed due to 6.3.7 [basic.scope.class] p1 rule 2: "A name N used in a class S shall refer to the same declaration in its context and when re-evaluated in the completed scope of S. No diagnostic is required for a violation of this rule." Core issue 1330 introduced delay-parsing for exception specifications. Due to the 6.3.7 [basic.scope.class] rules, this shouldn't have changed the behavior of any conforming programs. But it changes the behavior in the non-conforming case from "no diagnostic required" to "diagnostic required", so implementations that implement core issue 1330 are now required to diagnose the ill-formed declarations in the standard library. Suggested resolution: Add an is_nothrow_swappable trait, and use it throughout the library in place of these noexcept expressions.
No action for now; we intend to have papers for Lenexa.
Move to Open.Daniel: A first paper (N4426) exists to suggest some ways of solving this issue.
[2015-10, Kona, Daniel comments]
A revised paper (N4511) has been provided
[2015-12-16, Daniel comments]
Revision 2 (P0185R0) will available for the mid February 2016 mailing.
[2016-03, Jacksonville]P0185R1 was adopted in Jacksonville.