An rvalue reference that is to expire.
C defines a function designator as an expression that has function type. A function designator is distinct from an object type or an lvalue. It can be the name of a function or the result of dereferencing a function pointer. The C language also differentiates between its treatment of a function pointer and an object pointer.
A function call that returns an lvalue reference is an lvalue. Expressions can produce an lvalue, an xvalue, a (prvalue) rvalue, or no value.
Operator | Requirement |
---|---|
& (unary) | Operand must be an lvalue. |
++ -- | Operand must be a modifiable lvalue. This applies to both prefix and postfix forms. |
= += -= *= %= <<= >>= &= ‸= |= | Left operand must be a modifiable lvalue. |
For example, all assignment operators evaluate their right operand and assign that value to their left operand. The left operand must be a modifiable lvalue.
Expression | Lvalue |
---|---|
x = 42 | x |
*ptr = newvalue | *ptr |
a++ | a |
f() | The function call to f() |
int a;
int&& b= static_cast<int&&>(a);
struct str{
int c;
};
int&& f(){
int&& var =1;
return var;
}
str&& g();
int&& rc = g().c;
In this example, The initializer for rvalue reference b is
an xvalue because it is a result of a cast to an rvalue reference.
A call to the function f() produces an xvalue because
the return type of this function is of the int&& type.
The initializer for rvalue reference rc is an xvalue
because it is an expression that accesses a nonstatic non-reference
data member c through an xvalue expression.