4.1 左值到右值的转换 中英文对照(C++标准中文版 ISO/IEC 14882:2014)

4.1 Lvalue-to-rvalue conversion [conv.lval]
4.1 左值到右值的转换

1 A glvalue (3.10) of a non-function, non-array type T can be converted to a prvalue. [55: For historical reasons, this conversion is called the “lvalue-to-rvalue” conversion, even though that name does not accurately reflect the taxonomy of expressions described in 3.10.]

1 非函数、非数组类型T的泛化左值glvalue(3.10)可被转换为一个纯右值prvalue。[注55:由于历史原因,本转换被称为“左值到右值”转换,尽管该名称无法准确反映3.10中所述的表达式的分类系统。]
If T is an incomplete type, a program that necessitates this conversion is ill-formed. If T is a non-class type, the type of the prvalue is the cv-unqualified version of T. Otherwise, the type of the prvalue is T. [56:  In C ++ class prvalues can have cv-qualified types (because they are objects). This differs from ISO C, in which non-lvalues never have cv-qualified types.]
若T为不完整类型,那么要用到本转换的程序是不良形式的。若T为非class类型,则纯右值prvalue的类型是T的cv非限定版本。否则,纯右值的类型是T。[注56:在C++中,class纯右值可以具有cv限定类型(因为它们是对象)。这与ISO C不同,ISO C中非左值永远不具有cv限定类型。]

2 When an lvalue-to-rvalue conversion is applied to an expression e, and either
2 当左值到右值转换发生于表达式e,且不属于:
    — e is not potentially evaluated, or
    — e未被潜在求值,或
    — the evaluation of e results in the evaluation of a member ex of the set of potential results of e, and ex names a variable x that is not odr-used by ex (3.2), 
    — e的求值为这样的结果:e的潜在结果集合里的某成员ex之求值,且ex命名了一个未被ex odr-used变量x????(译者注:神啊,劈死该死的英文标准记录员吧。译者参不透本句啊!)
the value contained in the referenced object is not accessed. [Example:
被引用对象中包含的值不被访问。[例:
  struct S { int n; };
  auto f() {
    S x { 1 };
    constexpr S y { 2 };
    return [&](bool b) { return (b ? y : x).n; };
  }
  auto g = f();
  int m = g(false); // undefined behavior due to access of x.n outside its lifetime
                    // 未定义行为,因为访问x.n超出了其生存期
  int n = g(true); // OK, does not access y.n
                   // OK,不访问y.n
—end example ] In all other cases, the result of the conversion is determined according to the following rules:
—例结束] 所有情形下,本转换的结果根据以下规则来决定:

  — If T is (possibly cv-qualified) std::nullptr_t, the result is a null pointer constant (4.10).
  — 若T为(可能是cv限定的)std::nullptr_t,结果是null指针常量(4.10)。
  — Otherwise, if T has a class type, the conversion copy-initializes a temporary of type T from the glvalue and the result of the conversion is a prvalue for the temporary.
  — 否则,若T具有class类型,本转换由glvalue复制初始化一个类型T的临时对象,且转换结果是该临时对象的纯右值。
  — Otherwise, if the object to which the glvalue refers contains an invalid pointer value (3.7.4.2, 3.7.4.3), the behavior is implementation-defined.
  — 否则,若glvalue指代的对象中含有非法指针值(3.7.4.2, 3.7.4.3),行为由具体实现来定义
  — Otherwise, the value contained in the object indicated by the glvalue is the prvalue result.
  — 否则,glvalue指代对象中含有的值就是纯右值结果。

3 [Note: See also 3.10.—end note ]

3 [注:见3.10。——注结束]


  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值