“as if” in language standards

后端 未结 3 1790
旧时难觅i
旧时难觅i 2020-12-18 22:15

What is the exact meaning of the phrase \"as if\" in the standard and how does it work when a user can modify individual parts of the behavior.

The question is in re

3条回答
  •  天涯浪人
    2020-12-18 23:11

    If the change in allocator in operator new makes an observable difference in the behaviour of a compliant C++ program then yes, it might require a change in the implementation of the no-throw version. Specifically if operator delete expects only blocks allocated by the new allocator then the no-throw new must change.

    My reading is that the use of as if allows an implementation such as yours when the user hasn't overriden the standard operator new. As soon as he has, the implementation must not use a malloc based no-throw operator new and must either call the user declared version explicitly or at least re-use enough of the user declared version that a conforming program cannot tell that this isn't how the no-throw version has been implemented.

提交回复
热议问题