[conv]/6 (emphasis is mine):
The effect of any implicit conversion is the same as performing the corresponding declaration and initialization and then using the temporary variable as the result of the conversion. The result is an lvalue if T is an lvalue reference type or an rvalue reference to function type ([dcl.ref]), an xvalue if T is an rvalue reference to object type, and a prvalue otherwise. The expression e is used as a glvalue if and only if the initialization uses it as a glvalue.
What is the meaning of the highlighted statement above, in the context of this specific paragraph?
The intent of that sentence is to clarify that an expression like i
(where i
is a variable) is not spuriously treated as a glvalue in contexts in which i
is immediately converted to a prvalue.
For instance, in
int main() {
const int j = 0;
constexpr int i = j;
}
The second definition would be ill-formed if j
was considered a glvalue, as j
is not a permitted result of a constant expression. However, j
is used as a prvalue since the initialization uses it as one, hence the other rule in the linked paragraph applies (and the definition is well-formed).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With