declval里面,什么是"unevaluated context"?
cppreference的网站上,关于declval的介绍里面提到:(en.cppreference.com/w/cpp/utility/declval)------------------
Note that because no definition exists for declval, it can only be used in unevaluated contexts
------------------
我查了一下C++11的标准文档,里面并没有"unevaluated context"这样的表述。这个是编译原理的概念还是别的什么? 有没有比较好的中文解释呢?
谢谢。 瞎说,明明就写在标准里。
§ 5 ¶ 8:
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.
§ 5.2.8 ¶ 3:
When typeid is applied to an expression other than a glvalue of a polymorphic class type, the result refers to a std::type_info object representing the static type of the expression. Lvalue-to-rvalue (4.1), array-to-pointer (4.2), and function-to-pointer (4.3) conversions are not applied to the expression. If the type of the expression is a class type, the class shall be completely-defined. The expression is an unevaluated operand (Clause 5).
§ 5.3.3 ¶ 1:
The sizeof operator yields the number of bytes in the object representation of its operand. The operand is either an expression, which is an unevaluated operand (Clause 5), or a parenthesized type-id. The sizeof operator shall not be applied to an expression that has function or incomplete type, to an enumeration type whose underlying type is not fixed before all its enumerators have been declared, to the parenthesized name of such types, or to a glvalue that designates a bit-field.
§ 5.3.7 ¶ 1:
The noexcept operator determines whether the evaluation of its operand, which is an unevaluated operand (Clause 5), can throw an exception (15.1).
§ 7.1.6.2 ¶ 4.4:
The operand of the decltype specifier is an unevaluated operand (Clause 5).
页:
[1]