|
6588 | 6588 | \end{example}
|
6589 | 6589 |
|
6590 | 6590 | \pnum
|
| 6591 | +An \defnadj{implicitly movable}{entity} is |
| 6592 | +a variable of automatic storage duration |
| 6593 | +that is either a non-volatile object or |
| 6594 | +an rvalue reference to a non-volatile object type. |
6591 | 6595 | In the following copy-initialization contexts, a move operation might be used instead of a copy operation:
|
6592 | 6596 | \begin{itemize}
|
6593 | 6597 | \item If the \grammarterm{expression} in a \tcode{return} or \tcode{co_return} statement\iref{stmt.return}
|
6594 | 6598 | is a (possibly parenthesized) \grammarterm{id-expression}
|
6595 |
| -that names an object with automatic storage duration declared in the body |
| 6599 | +that names an implicitly movable entity declared in the body |
6596 | 6600 | or \grammarterm{parameter-declaration-clause} of the innermost enclosing
|
6597 | 6601 | function or \grammarterm{lambda-expression}, or
|
6598 | 6602 |
|
6599 | 6603 | \item if the operand of a \grammarterm{throw-expression}\iref{expr.throw}
|
6600 |
| -is the name of a non-volatile automatic object |
6601 |
| -(other than a function or catch-clause parameter) |
6602 |
| -whose scope does not extend beyond the end of the innermost enclosing |
6603 |
| -\grammarterm{try-block} (if there is one), |
| 6604 | +is a (possibly parenthesized) \grammarterm{id-expression} |
| 6605 | +that names an implicitly movable entity |
| 6606 | +whose scope does not extend beyond the \grammarterm{compound-statement} |
| 6607 | +of the innermost \grammarterm{try-block} or \grammarterm{function-try-block} |
| 6608 | +(if any) |
| 6609 | +whose \grammarterm{compound-statement} or \grammarterm{ctor-initializer} |
| 6610 | +encloses the \grammarterm{throw-expression}, |
6604 | 6611 | \end{itemize}
|
6605 | 6612 | overload resolution to select the constructor
|
6606 | 6613 | for the copy or the \tcode{return_value} overload to call
|
6607 |
| -is first performed as if the object were designated by an |
6608 |
| -rvalue. |
| 6614 | +is first performed as if the expression or operand were an rvalue. |
6609 | 6615 | If the first overload resolution fails or was not performed,
|
6610 |
| -or if the type of the first parameter of the selected |
6611 |
| -constructor or the \tcode{return_value} overload |
6612 |
| -is not an rvalue reference to the object's type (possibly cv-qualified), |
6613 |
| -overload resolution is performed again, considering the object as an lvalue. |
| 6616 | +overload resolution is performed again, |
| 6617 | +considering the expression or operand as an lvalue. |
6614 | 6618 | \begin{note}
|
6615 | 6619 | This two-stage overload resolution must be performed regardless
|
6616 | 6620 | of whether copy elision will occur. It determines the constructor
|
6617 | 6621 | or the \tcode{return_value} overload to be called if
|
6618 | 6622 | elision is not performed, and the selected constructor
|
6619 |
| -or the \tcode{return_value} overload must be accessible even if |
| 6623 | +or \tcode{return_value} overload must be accessible even if |
6620 | 6624 | the call is elided.
|
6621 | 6625 | \end{note}
|
6622 | 6626 |
|
|
6653 | 6657 | \end{codeblock}
|
6654 | 6658 | \end{example}
|
6655 | 6659 |
|
| 6660 | +\pnum |
| 6661 | +\begin{example} |
| 6662 | +\begin{codeblock} |
| 6663 | +void f() { |
| 6664 | + T x; |
| 6665 | + try { |
| 6666 | + T y; |
| 6667 | + try { g(x); } |
| 6668 | + catch (...) { |
| 6669 | + if (/*...*/) |
| 6670 | + throw x; // does not move |
| 6671 | + throw y; // moves |
| 6672 | + } |
| 6673 | + g(y); |
| 6674 | + } catch(...) { |
| 6675 | + g(x); |
| 6676 | + // g(y); // error |
| 6677 | + } |
| 6678 | +} |
| 6679 | +\end{codeblock} |
| 6680 | +\end{example} |
| 6681 | + |
6656 | 6682 | \rSec1[class.compare]{Comparisons}%
|
6657 | 6683 |
|
6658 | 6684 | \rSec2[class.compare.default]{Defaulted comparison operator functions}%
|
|
0 commit comments