Skip to content

Commit b502b60

Browse files
committed
[containers] Tentative P/R for [LWG4123] "Container effects use..."
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.
1 parent f1379f5 commit b502b60

File tree

1 file changed

+28
-33
lines changed

1 file changed

+28
-33
lines changed

source/containers.tex

+28-33
Original file line numberDiff line numberDiff line change
@@ -6841,8 +6841,8 @@
68416841
implementation-specific optimizations.
68426842
\end{note}
68436843
If the size is equal to the old capacity, or
6844-
if an exception is thrown other than by the move constructor
6845-
of a non-\oldconcept{CopyInsertable} \tcode{T},
6844+
if an exception is thrown other than by
6845+
the move-construction of one object of non-\oldconcept{CopyInsertable} type \tcode{T} from another,
68466846
then there are no effects.
68476847

68486848
\pnum
@@ -6908,16 +6908,14 @@
69086908

69096909
\pnum
69106910
\remarks
6911-
If an exception is thrown other than by the
6912-
copy constructor, move constructor,
6913-
assignment operator, or move assignment operator of
6914-
\tcode{T},
6911+
If an exception is thrown other than by
6912+
the construction or assignment of one object of type \tcode{T} from another,
69156913
there are no effects.
69166914
If an exception is thrown while inserting a single element at either end,
69176915
there are no effects.
6918-
Otherwise, if an exception is thrown by the move constructor of a
6919-
non-\oldconcept{CopyInsertable}
6920-
\tcode{T}, the effects are unspecified.
6916+
Otherwise, if an exception is thrown by
6917+
the move-construction of one object of non-\oldconcept{CopyInsertable} type \tcode{T} from another,
6918+
the effects are unspecified.
69216919
\end{itemdescr}
69226920

69236921
\indexlibrarymember{erase}{deque}%
@@ -6943,8 +6941,8 @@
69436941

69446942
\pnum
69456943
\throws
6946-
Nothing unless an exception is thrown by the assignment operator of
6947-
\tcode{T}.
6944+
Nothing unless an exception is thrown by
6945+
the assignment of one object of type \tcode{T} from another.
69486946

69496947
\pnum
69506948
\complexity
@@ -8966,8 +8964,8 @@
89668964
otherwise.
89678965
Reallocation happens at this point if and only if the current capacity is less than the
89688966
argument of
8969-
\tcode{reserve()}. If an exception is thrown
8970-
other than by the move constructor of a non-\oldconcept{CopyInsertable} type,
8967+
\tcode{reserve()}. If an exception is thrown other than by
8968+
the move-construction of one object of non-\oldconcept{CopyInsertable} type \tcode{T} from another,
89718969
there are no effects.
89728970

89738971
\pnum
@@ -9017,8 +9015,9 @@
90179015
\end{note}
90189016
It does not increase \tcode{capacity()}, but may reduce \tcode{capacity()}
90199017
by causing reallocation.
9020-
If an exception is thrown other than by the move constructor
9021-
of a non-\oldconcept{CopyInsertable} \tcode{T}, there are no effects.
9018+
If an exception is thrown other than by
9019+
the move-construction of one object of non-\oldconcept{CopyInsertable} type \tcode{T} from another,
9020+
there are no effects.
90229021

90239022
\pnum
90249023
\complexity
@@ -9074,8 +9073,9 @@
90749073

90759074
\pnum
90769075
\remarks
9077-
If an exception is thrown other than by the move constructor of a non-\oldconcept{CopyInsertable}
9078-
\tcode{T}, there are no effects.
9076+
If an exception is thrown other than by
9077+
the move-construction of one object of non-\oldconcept{CopyInsertable} type \tcode{T} from another,
9078+
there are no effects.
90799079
\end{itemdescr}
90809080

90819081
\indexlibrarymember{resize}{vector}%
@@ -9161,15 +9161,15 @@
91619161
including the past-the-end iterator,
91629162
are invalidated.
91639163
If an exception is thrown other than by
9164-
the copy constructor, move constructor,
9165-
assignment operator, or move assignment operator of
9166-
\tcode{T} or by any \tcode{InputIterator} operation,
9164+
the construction or assignment of one object of type \tcode{T} from another,
9165+
or by any \tcode{InputIterator} operation,
91679166
there are no effects.
91689167
If an exception is thrown while inserting a single element at the end and
91699168
\tcode{T} is \oldconcept{CopyInsertable} or \tcode{is_nothrow_move_constructible_v<T>}
91709169
is \tcode{true}, there are no effects.
9171-
Otherwise, if an exception is thrown by the move constructor of a non-\oldconcept{CopyInsertable}
9172-
\tcode{T}, the effects are unspecified.
9170+
Otherwise, if an exception is thrown by
9171+
the move-construction of one object of non-\oldconcept{CopyInsertable} type \tcode{T} from another,
9172+
the effects are unspecified.
91739173
\end{itemdescr}
91749174

91759175
\indexlibrarymember{erase}{vector}%
@@ -9186,9 +9186,8 @@
91869186

91879187
\pnum
91889188
\throws
9189-
Nothing unless an exception is thrown by the
9190-
assignment operator or move assignment operator of
9191-
\tcode{T}.
9189+
Nothing unless an exception is thrown by
9190+
the construction or assignment of one object of type \tcode{T} from another.
91929191

91939192
\pnum
91949193
\complexity
@@ -9893,13 +9892,9 @@
98939892

98949893
\pnum
98959894
\remarks
9896-
If an exception is thrown other than by the
9897-
copy constructor,
9898-
move constructor,
9899-
assignment operator, or
9900-
move assignment operator
9901-
of \tcode{T} or by
9902-
any \tcode{InputIterator} operation,
9895+
If an exception is thrown other than by
9896+
the construction or assignment of one object of type \tcode{T} from another,
9897+
or by any \tcode{InputIterator} operation,
99039898
there are no effects.
99049899
Otherwise,
99059900
if an exception is thrown, then
@@ -10097,7 +10092,7 @@
1009710092
\pnum
1009810093
\throws
1009910094
Nothing unless an exception is thrown by
10100-
the assignment operator or move assignment operator of \tcode{T}.
10095+
the assignment of one object of type \tcode{T} from another.
1010110096

1010210097
\pnum
1010310098
\complexity

0 commit comments

Comments
 (0)