Topic: question re overloaded operator new() and constructors


Author: brucec@phoebus.labs.tek.com (Bruce Cohen;;50-662;LP=A;)
Date: 5 Feb 91 00:55:35 GMT
Raw View
Section 5.3.3 (page 61) of the ARM states:

"Whether operator new allocates the memory itself or leaves that up to the
constructor when creating an object of a class with a constructor is
implementation dependent.

    O It will, however, always be allocated without the intervention of the
    programmer.  Calling operator new() as part of the implementation of
    an allocation-expression is the task of an implementation."

Could someone please explain to me how one can then guarantee that an
overloaded operator new() can do the right thing in regards to allocation?
In other words, if it's up to the compiler writer whether the constructor
allocates or not, how can I, as a programmer, put special purpose
allocation into my new?  Or should there be an additional statement in the
ARM to the effect that constructors of classes which overload new() cannot
allocate memory?
--
------------------------------------------------------------------------
Speaker-to-managers, aka
Bruce Cohen, Computer Research Lab        email: brucec@tekchips.labs.tek.com
Tektronix Laboratories, Tektronix, Inc.                phone: (503)627-5241
M/S 50-662, P.O. Box 500, Beaverton, OR  97077