[containers] Tentative P/R for [LWG4123] "Container effects use..." #7207
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Attn @jwakely. This PR isn't editorial; it's for LWG editor's benefit. I'll turn it into a "Draft" ASAP, if GitHub lets me do that.
https://cplusplus.github.io/LWG/issue4123
The superficial problem here is that "assignment operator or move assignment operator" is redundant. The real problem is that the container might use an assignment operator that's not a copy-or-move assignment operator, and/or a constructor that's not a copy-or-move constructor.
We want to preserve the idea of "constructing or assigning a T from another T," as opposed to from a U. But we want to permit all the various ways of doing that, such as "implicitly convert the source T to U, then assign from U to T," as shown in this Godbolt: https://godbolt.org/z/8Ybbxr19e
(If one of those various ways throws, then there might be effects, even though the throwing culprit wasn't a constructor or assignment operator of
T
at all.)We have similar problems in [optional], e.g.
https://eel.is/c++draft/optional.optional#optional.ctor-6
"Any exception thrown by the selected constructor of T."
(Overload resolution might select a conversion operator, not a constructor.)
https://eel.is/c++draft/optional.optional#optional.assign-7
"If an exception is thrown during the call to T's copy constructor, no effect.
If an exception is thrown during the call to T's copy assignment, the state
of its contained value is as defined by the exception safety guarantee of T's
copy assignment."
(Overload resolution might select a constructor that is not a copy constructor,
resp. an assignment [operator] that is not a copy assignment operator.)
I have not attempted to fix those problems in this patch.