“好像"的陈述或依据在哪里?C ++标准中的规则? [英] Where are the statement of or the foundations for the "as if" rule in the C++ Standard?

查看:45
本文介绍了“好像"的陈述或依据在哪里?C ++标准中的规则?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过一番Google搜索(例如, site:eel.is是好像规则" ),我找不到合适的位置来清楚地陈述所谓的好像"规则在C ++标准中.我所能找到的就是在标准中调用它的那些地方,给出了 intro.execution 参考.

After a little google search (for instance, site:eel.is "as if rule") I couldn't find a proper place where the so called "as if" rule is clearly stated in the C++ standard. All I could find is that in those places within the standard where it is invoked, the intro.execution reference is given.

但是 intro.execution 似乎没有明确引用此规则的任何一般形式.我可能在这里缺少一些细微的东西,但是您能指出我对传达规则有精确的规范理解的地方吗?也许整个 intro.execution 确实旨在传达我们所谓的好像"规则在野外吗?我承认我只是浏览了一下.

But intro.execution doen't seem to clearly reference any general form of this rule. I'm probably missing something subtle here, but can you point me to the place, or places, where a precise normative understanding of the rule is conveyed? Maybe the whole intro.execution is indeed intended to convey what we call as the "as if" rule in the wild? I confess that I've just skimmed through it.

我正在使用此网站浏览该标准的工作草案.

I'm using this website to navigate through the working draft of the standard.

例如,可以在 cppreference中找到好像"规则的定义网站,例如,出于优化原因,允许编译器在满足某些约束的情况下对程序执行转换.

The definition of the "as if" rule can be found, for instance in the cppreference site, as something to the effect that compilers are allowed to perform transformations on programs as long as some constraints are met, for optimizations reasons, for instance.

推荐答案

好像"规则的定义在4.1.1/1的脚注中给出.参见 http://eel.is/c++draft/intro.abstract#footnote-4 :

The definition for "as if" rule is given in the footnote to 4.1.1/1. See http://eel.is/c++draft/intro.abstract#footnote-4:

该规定有时称为假设"规则,因为实施过程可以随意忽略本文档的任何要求只要结果是好像已经满足了要求,可以从程序的可观察行为确定.为了例如,实际的实现无需评估部分表达式,如果可以推断出它的值未使用并且没有影响程序可观察行为的副作用是产生.

This provision is sometimes called the "as-if" rule, because an implementation is free to disregard any requirement of this document as long as the result is as if the requirement had been obeyed, as far as can be determined from the observable behavior of the program. For instance, an actual implementation need not evaluate part of an expression if it can deduce that its value is not used and that no side effects affecting the observable behavior of the program are produced.

这篇关于“好像"的陈述或依据在哪里?C ++标准中的规则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆