![]() |
От: |
rg45
|
|
Дата: | 01.02.25 11:10 | ||
Оценка: | 2 (1) |
The expression is an xvalue if it is move-eligible (see below); an lvalue if the entity is a function, variable, structured binding, data member, or template parameter object; and a prvalue otherwise ([basic.lval]); it is a bit-field if the identifier designates a bit-field.
An implicitly movable entity is a variable of automatic storage duration that is either a non-volatile object or an rvalue reference to a non-volatile object type.
In the following contexts, an id-expression is move-eligible:
(4.1) If the id-expression (possibly parenthesized) is the operand of a return ([stmt.return]) or co_return ([stmt.return.coroutine]) statement, and names an implicitly movable entity declared in the body or parameter-declaration-clause of the innermost enclosing function or lambda-expression, or
(4.2) if the id-expression (possibly parenthesized) is the operand of a throw-expression ([expr.throw]), and names an implicitly movable entity that belongs to a scope that does not contain the compound-statement of the innermost lambda-expression, try-block, or function-try-block (if any) whose compound-statement or ctor-initializer contains the throw-expression.
template <typename T>
T&& foo(T&& t)
{
modify(t);
return std::forward<T>(t);
}
auto&& foo(auto&& t)
{
modify(t);
return t;
}