Skip to content

Lvalue to rvalue conversion

stackoverflow lvalue to rvalue implicit conversion

NOTE: 没有读懂

josephmansfield C++ sequenced-before graphs

For those who want to read more, look up value categories. The left operand of = is an lvalue, which means that we don't care about its value. Lvalue-to-rvalue conversion can be thought of as reading the value from an object.

cppreference Implicit conversions # Value transformations # Lvalue to rvalue conversion

A glvalue of any non-function, non-array type T can be implicitly converted to a prvalue of the same type. If T is a non-class type, this conversion also removes cv-qualifiers.

NOTE: 思考:

1、这种conversion在什么情况下会发生? 有没有example

The object denoted by the glvalue is not accessed if:

NOTE: "is not accessed"是什么含义?

1、the conversion occurs in an unevaluated context (outside an immediate invocation) (since C++20), such as an operand of sizeof, noexcept, decltype, (since C++11) or the static form of typeid

2、the glvalue has the type std::nullptr_t: in this case the resulting prvalue is the null pointer constant nullptr. (since C++11)

3、the value stored in the object is a compile-time constant and certain other conditions are satisfied (see ODR-use)

This conversion models the act of reading a value from a memory location into a CPU register.

NOTE: 这段是理解的关键,它提醒了我:

1、value semantic