|
6178 | 6178 | \indextext{constructor!copy!elision}%
|
6179 | 6179 | \indextext{constructor!move!elision}%
|
6180 | 6180 | 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 |
6183 | 6184 | destructor for the object have
|
6184 | 6185 | \indextext{side effects}%
|
6185 | 6186 | side effects. In such cases, the
|
6186 | 6187 | 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 |
6188 | 6189 | referring to the same object. If the first parameter of the
|
6189 | 6190 | selected constructor is an rvalue reference to the object's type,
|
6190 | 6191 | the destruction of that object occurs when the target would have been destroyed;
|
6191 | 6192 | otherwise, the destruction occurs at the later of the times when the
|
6192 | 6193 | two objects would have been destroyed without the
|
6193 | 6194 | optimization.
|
6194 |
| -\begin{footnote} |
| 6195 | +\begin{note} |
6195 | 6196 | 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 |
6200 | 6201 | \indexdefn{copy elision|see{constructor, copy, elision}}%
|
6201 | 6202 | \indexdefn{elision!copy|see{constructor, copy, elision}}%
|
6202 | 6203 | \indexdefn{constructor!copy!elision}\indexdefn{constructor!move!elision}\term{copy elision},
|
6203 | 6204 | is permitted in the
|
6204 | 6205 | following circumstances (which may be combined to
|
6205 | 6206 | eliminate multiple copies):
|
6206 | 6207 | \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, |
6208 | 6210 | 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 |
6210 | 6212 | 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; |
6216 | 6217 |
|
6217 | 6218 | \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}) |
6220 | 6223 | that belongs to a scope that does not contain
|
6221 | 6224 | the innermost enclosing \grammarterm{compound-statement}
|
6222 | 6225 | 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; |
6225 | 6228 |
|
6226 | 6229 | \item in a coroutine\iref{dcl.fct.def.coroutine}, a copy of a coroutine parameter
|
6227 | 6230 | can be omitted and references to that copy replaced with references to the
|
6228 | 6231 | 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; |
6230 | 6233 |
|
6231 | 6234 | \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 |
6235 | 6237 | the \grammarterm{exception-declaration} as an alias for the exception
|
6236 | 6238 | object if the meaning of the program will be unchanged except for the execution
|
6237 | 6239 | of constructors and destructors for the object declared by the
|
|
0 commit comments