Skip to content

Commit 32026a5

Browse files
jensmaurerzygoloid
authored andcommitted
[class.copy] Rephrase rule preferring a move constructor
in a throw-expression or a return statement. Fixes #712.
1 parent 19a0c06 commit 32026a5

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

source/special.tex

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3203,17 +3203,23 @@
32033203
\end{example}
32043204

32053205
\pnum
3206-
When the criteria for elision of a copy/move operation are met,
3207-
but not for an \nonterminal{exception-declaration},
3208-
and the object
3209-
to be copied is designated by an lvalue,
3210-
or when the \grammarterm{expression} in a \tcode{return} statement
3206+
In the following copy-initialization contexts, a move operation might be used instead of a copy operation:
3207+
\begin{itemize}
3208+
\item If the \grammarterm{expression} in a \tcode{return} statement~(\ref{stmt.return})
32113209
is a (possibly parenthesized) \grammarterm{id-expression}
32123210
that names an object with automatic storage duration declared in the body
32133211
or \grammarterm{parameter-declaration-clause} of the innermost enclosing
3214-
function or \grammarterm{lambda-expression},
3212+
function or \grammarterm{lambda-expression}, or
3213+
3214+
\item if the operand of a \grammarterm{throw-expression}~(\ref{expr.throw})
3215+
is the name of a non-volatile automatic object
3216+
(other than a function or catch-clause parameter)
3217+
whose scope does not extend beyond the end of the innermost enclosing
3218+
\grammarterm{try-block} (if there is one),
3219+
\end{itemize}
32153220
overload resolution to select the constructor
3216-
for the copy is first performed as if the object were designated by an rvalue.
3221+
for the copy is first performed as if the object were designated by an
3222+
rvalue.
32173223
If the first overload resolution fails or was not performed,
32183224
or if the type of the first parameter of the selected
32193225
constructor is not an rvalue reference to the object's type (possibly cv-qualified),
@@ -3224,6 +3230,8 @@
32243230
elision is not performed, and the selected constructor must be accessible even if
32253231
the call is elided.
32263232
\end{note}
3233+
3234+
\pnum
32273235
\begin{example}
32283236
\begin{codeblock}
32293237
class Thing {

0 commit comments

Comments
 (0)