Skip to content

Commit 018efd1

Browse files
burblebeetkoeppe
authored andcommitted
CWG2930 Unclear term "copy/move operation" in specification of copy elision
1 parent 6280657 commit 018efd1

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

source/classes.tex

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6178,60 +6178,62 @@
61786178
\indextext{constructor!copy!elision}%
61796179
\indextext{constructor!move!elision}%
61806180
When certain criteria are met, an implementation is
6181-
allowed to omit the copy/move construction of a class object,
6182-
even if the constructor selected for the copy/move operation and/or the
6181+
allowed to omit the creation of a class object from
6182+
a source object of the same type (ignoring cv-qualification),
6183+
even if the selected constructor and/or the
61836184
destructor for the object have
61846185
\indextext{side effects}%
61856186
side effects. In such cases, the
61866187
implementation treats the source and target of the
6187-
omitted copy/move operation as simply two different ways of
6188+
omitted initialization as simply two different ways of
61886189
referring to the same object. If the first parameter of the
61896190
selected constructor is an rvalue reference to the object's type,
61906191
the destruction of that object occurs when the target would have been destroyed;
61916192
otherwise, the destruction occurs at the later of the times when the
61926193
two objects would have been destroyed without the
61936194
optimization.
6194-
\begin{footnote}
6195+
\begin{note}
61956196
Because only one object is destroyed instead of two,
6196-
and one copy/move constructor
6197-
is not executed, there is still one object destroyed for each one constructed.
6198-
\end{footnote}
6199-
This elision of copy/move operations, called
6197+
and the creation of one object is omitted,
6198+
there is still one object destroyed for each one constructed.
6199+
\end{note}
6200+
This elision of object creation, called
62006201
\indexdefn{copy elision|see{constructor, copy, elision}}%
62016202
\indexdefn{elision!copy|see{constructor, copy, elision}}%
62026203
\indexdefn{constructor!copy!elision}\indexdefn{constructor!move!elision}\term{copy elision},
62036204
is permitted in the
62046205
following circumstances (which may be combined to
62056206
eliminate multiple copies):
62066207
\begin{itemize}
6207-
\item in a \tcode{return} statement in a function with a class return type,
6208+
\item in a \tcode{return} statement\iref{stmt.return} in
6209+
a function with a class return type,
62086210
when the \grammarterm{expression} is the name of a non-volatile
6209-
object with automatic storage duration (other than a function parameter or a variable
6211+
object $o$ with automatic storage duration (other than a function parameter or a variable
62106212
introduced by the \grammarterm{exception-declaration} of a
6211-
\grammarterm{handler}\iref{except.handle})
6212-
with the same type (ignoring cv-qualification) as
6213-
the function return type, the copy/move operation can be
6214-
omitted by constructing the object directly
6215-
into the function call's return object
6213+
\grammarterm{handler}\iref{except.handle}),
6214+
the copy-initialization of the result object can be
6215+
omitted by constructing $o$ directly
6216+
into the function call's result object;
62166217

62176218
\item in a \grammarterm{throw-expression}\iref{expr.throw}, when the operand
6218-
is the name of a non-volatile object with automatic storage duration
6219-
(other than a function or catch-clause parameter)
6219+
is the name of a non-volatile object $o$ with automatic storage duration
6220+
(other than a function parameter or
6221+
a variable introduced by
6222+
the \grammarterm{exception-declaration} of a \grammarterm{handler})
62206223
that belongs to a scope that does not contain
62216224
the innermost enclosing \grammarterm{compound-statement}
62226225
associated with a \grammarterm{try-block} (if there is one),
6223-
the copy/move operation can be omitted by
6224-
constructing the object directly into the exception object
6226+
the copy-initialization of the exception object can be omitted by
6227+
constructing $o$ directly into the exception object;
62256228

62266229
\item in a coroutine\iref{dcl.fct.def.coroutine}, a copy of a coroutine parameter
62276230
can be omitted and references to that copy replaced with references to the
62286231
corresponding parameter if the meaning of the program will be unchanged except for
6229-
the execution of a constructor and destructor for the parameter copy object
6232+
the execution of a constructor and destructor for the parameter copy object;
62306233

62316234
\item when the \grammarterm{exception-declaration} of a
6232-
\grammarterm{handler}\iref{except.handle} declares an object of the same
6233-
type (except for cv-qualification) as the exception
6234-
object\iref{except.throw}, the copy operation can be omitted by treating
6235+
\grammarterm{handler}\iref{except.handle} declares an object $o$,
6236+
the copy-initialization of $o$ can be omitted by treating
62356237
the \grammarterm{exception-declaration} as an alias for the exception
62366238
object if the meaning of the program will be unchanged except for the execution
62376239
of constructors and destructors for the object declared by the

0 commit comments

Comments
 (0)