[英]What is a potentially-evaluated expression?
I am reading about ODR-use and I encountered this: 我正在阅读有关ODR使用的信息 ,遇到了以下问题:
a variable x in a potentially-evaluated expression ex is odr-used unless both of the following are true:
除非满足以下两个条件,否则将使用可能评估的表达式ex中的变量x:
What is a potentially-evaluated expression ? 什么是可能评估的表达式 ?
Update: I might just found the answer when rolling down the page: 更新:向下滚动页面时,我可能只是找到答案了:
In the definitions above, potentially-evaluated means the expression is not an unevaluated operand (or its subexpression), such as the operand of sizeof and a set of potential results of an expression e is a (possibly empty) set of id-expressions that appear within e, combined as follows:
在上面的定义中,潜在赋值表示表达式不是未赋值的操作数(或其子表达式),例如sizeof的操作数,表达式e的一组潜在结果是一组id表达式(可能为空),出现在e中,组合如下:
But not sure if this is what it means in general + I do not really understand their explanation anyway. 但是不确定这是否意味着总体+我还是不太了解他们的解释。 Also, why to say potential result instead of just result ?
另外,为什么要说潜在结果而不是仅仅结果 ?
In simplest terms, potentially-evaluated is exactly what it says it is: the expression has a chance to be evaluated. 用最简单的术语来说,潜在评估就是它所说的:表达式有机会被评估。 This includes anything except
sizeof(ex)
, decltype(ex)
, typeid(ex)
and noexcept(ex)
. 这包括
sizeof(ex)
, decltype(ex)
, typeid(ex)
和noexcept(ex)
。 Other than in these contexts, ex is potentially-evaluated. 除了在这些情况下, ex都可能进行评估。
In relation to odr-used, it means x is considered odr-used only if ex is potentially-evaluated. 关于odr-used,这意味着x仅当ex可能被评估时才被视为odr-used。 That is to say, the necessary condition for x to be odr-used is that ex must be potentially-evaluated.
也就是说,要使用x的必要条件是必须对ex进行潜在评估。 This enables things such as
这使诸如
struct S
{
static float f; // declared but not defined
};
decltype(&S::f) p1; // since &S::f isn't potentially evaluated, this is well-formed
float* p2 = &S::f; // this is ill-formed
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.