Files
cppdraft_translate/cppdraft/expr/context.md
2025-10-25 03:02:53 +03:00

101 lines
4.4 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[expr.context]
# 7 Expressions [[expr]](./#expr)
## 7.2 Properties of expressions [[expr.prop]](expr.prop#expr.context)
### 7.2.3 Context dependence [expr.context]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L438)
In some contexts, [*unevaluated operands*](#def:unevaluated_operand "7.2.3Context dependence[expr.context]") appear ([[expr.prim.req.simple]](expr.prim.req.simple "7.5.8.2Simple requirements"), [[expr.prim.req.compound]](expr.prim.req.compound "7.5.8.4Compound requirements"), [[expr.typeid]](expr.typeid "7.6.1.8Type identification"), [[expr.sizeof]](expr.sizeof "7.6.2.5Sizeof"), [[expr.unary.noexcept]](expr.unary.noexcept "7.6.2.7noexcept operator"), [[expr.reflect]](expr.reflect "7.6.2.10The reflection operator"), [[dcl.type.decltype]](dcl.type.decltype "9.2.9.6Decltype specifiers"), [[temp.pre]](temp.pre "13.1Preamble"), [[temp.concept]](temp.concept "13.7.9Concept definitions"))[.](#1.sentence-1)
An unevaluated operand is not evaluated[.](#1.sentence-2)
[*Note [1](#note-1)*:
In an unevaluated operand, a non-static class member can be
named ([[expr.prim.id]](expr.prim.id "7.5.5Names")) and naming of objects or functions does not, by
itself, require that a definition be provided ([[basic.def.odr]](basic.def.odr "6.3One-definition rule"))[.](#1.sentence-3)
An unevaluated operand is considered a [full-expression](intro.execution#def:full-expression "6.10.1Sequential execution[intro.execution]")[.](#1.sentence-4)
— *end note*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L458)
In some contexts, an expression only appears for its side effects[.](#2.sentence-1)
Such an
expression is called a [*discarded-value expression*](#def:discarded-value_expression "7.2.3Context dependence[expr.context]")[.](#2.sentence-2)
The [array-to-pointer](conv.array "7.3.3Array-to-pointer conversion[conv.array]") and [function-to-pointer](conv.func "7.3.4Function-to-pointer conversion[conv.func]") standard conversions are not
applied[.](#2.sentence-3)
The [lvalue-to-rvalue](conv.lval "7.3.2Lvalue-to-rvalue conversion[conv.lval]") conversion is applied
if and only if
the expression is a glvalue of volatile-qualified type and it is one of the
following:
- [(2.1)](#2.1)
( [*expression*](expr.comma#nt:expression "7.6.20Comma operator[expr.comma]") ), where[*expression*](expr.comma#nt:expression "7.6.20Comma operator[expr.comma]") is one of these expressions,
- [(2.2)](#2.2)
[*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1General[expr.prim.id.general]") ([[expr.prim.id]](expr.prim.id "7.5.5Names")),
- [(2.3)](#2.3)
[*splice-expression*](expr.prim.splice#nt:splice-expression "7.5.9Expression splicing[expr.prim.splice]") ([[expr.prim.splice]](expr.prim.splice "7.5.9Expression splicing")),
- [(2.4)](#2.4)
[subscripting](expr.sub "7.6.1.2Subscripting[expr.sub]"),
- [(2.5)](#2.5)
[class member access](expr.ref "7.6.1.5Class member access[expr.ref]"),
- [(2.6)](#2.6)
[indirection](expr.unary.op#def:indirection "7.6.2.2Unary operators[expr.unary.op]"),
- [(2.7)](#2.7)
[pointer-to-member operation](expr.mptr.oper "7.6.4Pointer-to-member operators[expr.mptr.oper]"),
- [(2.8)](#2.8)
[conditional expression](expr.cond "7.6.16Conditional operator[expr.cond]") where both the second and the
third operands are one of these expressions, or
- [(2.9)](#2.9)
[comma expression](expr.comma "7.6.20Comma operator[expr.comma]") where the right operand is one of
these expressions[.](#2.sentence-4)
[*Note [2](#note-2)*:
Using an overloaded operator causes a function call; the
above covers only operators with built-in meaning[.](#2.sentence-5)
— *end note*]
The temporary materialization conversion ([[conv.rval]](conv.rval "7.3.5Temporary materialization conversion")) is applied
if the (possibly converted) expression is a prvalue of object type[.](#2.sentence-6)
[*Note [3](#note-3)*:
If the original expression is an lvalue of class type,
it must have a volatile copy constructor to initialize the temporary object
that is the result object of the temporary materialization conversion[.](#2.sentence-7)
— *end note*]
The expression is evaluated and its result (if any) is discarded[.](#2.sentence-8)