What are unevaluated contexts in C++?

前端 未结 2 960
广开言路
广开言路 2020-12-02 22:38

One example that frequently comes to mind is :

sizeof expression, where it doesn\'t evaluates the expression but determines the size by static type. For

2条回答
  •  误落风尘
    2020-12-02 23:02

    The standard term is an unevaluated operand and you can find it in [expr]

    In some contexts, unevaluated operands appear (5.2.8, 5.3.3, 5.3.7, 7.1.6.2). An unevaluated operand is not evaluated. An unevaluated operand is considered a full-expression. [ Note: In an unevaluated operand, a non-static class member may be named (5.1) and naming of objects or functions does not, by itself, require that a definition be provided (3.2). —end note ]

    • 5.2.8 covers typeid
    • 5.3.3 covers sizeof
    • 5.3.7 covers noexcept
    • 7.1.6.2 covers simple type specifiers such as auto and decltype and POD types like int, char, double etc.

提交回复
热议问题