A glvalue ([basic.lval]) of a non-function, non-array type T can be converted to a prvalue.55 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
When an lvalue-to-rvalue conversion is applied to an expression e, and either
e is not potentially evaluated, or
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 ([basic.def.odr]),
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); int n = g(true);
— 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 ([conv.ptr]).
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.
Otherwise, if the object to which the glvalue refers contains an invalid pointer value ([basic.stc.dynamic.deallocation], [basic.stc.dynamic.safety]), the behavior is implementation-defined.
Otherwise, the value contained in the object indicated by the glvalue is the prvalue result.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4