[conv]/6(重点是我的):
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.
在此特定段落的上下文中,突出显示的声明的含义是什么?
最佳答案 该句子的意图是澄清像i这样的表达式(其中i是一个变量)在上下文中被立即转换为prvalue而不被虚假地视为glvalue.
例如,在
int main() {
const int j = 0;
constexpr int i = j;
}
如果j被认为是一个glvalue,则第二个定义将是错误的,如j
is not a permitted result of a constant expression.然而,j被用作prvalue,因为初始化将其用作一个,因此链接段落中的另一个规则适用(并且定义很好 – 形成).