Created on 2015-12-11.00:00:00 last changed 29 months ago
[ 2020-03-30; Daniel comments ]
This has strong overlap with LWG 3413, which describes a sub-set of the problem here. Rebasing of the library fundamentals on C++20 has removed the mentioned problem for optionals free swap, so there are now no longer any further free swap function templates with conditionally noexcept specifications except for propagate_const (but now handled by LWG 3413).
[ 2016-11-08, Issaquah ]
Not adopted during NB comment resolution
[ 2016-03, Jacksonville ]
Add a link to 2456[ 2016-02-20, Daniel comments ]
A recent paper update has been provided: P0185R0.
[ 2016-02-20, Ville comments ]
Feedback from an implementation:
libstdc++ already applies the proposed resolution for propagate_const, but not for optional.Addresses: fund.ts.v2
As pointed out in N4511, the Library fundamentals are affected by a similar problem as described in LWG 2456. First, it is caused by optional's member swap ([optional.object.swap]):
void swap(optional<T>& rhs) noexcept(see below);
with
The expression inside noexcept is equivalent to:
is_nothrow_move_constructible_v<T> && noexcept(swap(declval<T&>(), declval<T&>()))
Again, the unqualified lookup for swap finds the member swap instead of the result of a normal argument-depending lookup, making this ill-formed.
A second example of such a problem recently entered the arena with the addition of the propagate_const template with another member swap ([propagate_const.modifiers]):constexpr void swap(propagate_const& pt) noexcept(see below);-2- The constant-expression in the exception-specification is noexcept(swap(t_, pt.t_)).
A working approach is presented in N4511. By adding a new trait to the standard library and referencing this by the library fundamentals (A similar approach had been applied in the file system specification where the quoted manipulator from C++14 had been referred to, albeit the file system specification is generally based on the C++11 standard), optional's member swap exception specification could be rephrased as follows:
The expression inside noexcept is equivalent to:
is_nothrow_move_constructible_v<T> && is_nothrow_swappable_v<T>noexcept(swap(declval<T&>(), declval<T&>()))
and propagate_const's member swap exception specification could be rephrased as follows:
constexpr void swap(propagate_const& pt) noexcept(see below);-2- The constant-expression in the exception-specification is is_nothrow_swappable_v<T>
noexcept(swap(t_, pt.t_)).
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-07-28 12:27:44 | admin | set | messages: + msg12659 |
2022-07-28 12:27:44 | admin | set | status: new -> resolved |
2020-03-30 16:29:55 | admin | set | messages: + msg11184 |
2016-11-20 18:58:35 | admin | set | messages: + msg8653 |
2016-03-07 04:46:57 | admin | set | messages: + msg8004 |
2016-02-20 20:56:18 | admin | set | messages: + msg7983 |
2016-02-20 20:56:18 | admin | set | messages: + msg7982 |
2015-12-11 00:00:00 | admin | create |