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
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.