The expression operator new(sizeof(T))
allocates T
bytes via ::operator new
, correct?
Is there any way to call the class-specific version of operator new
if it exists, exactly the way how new T()
allocates memory (before calling the constructor)?
T::operator new(sizeof(T))
gives a compile-time error if T
does not define operator new
, even if T
inherits from a base class that defines it. What I would like to call is:
Foo::operator new
ifFoo
definesoperator new
Base::operator new
ifFoo
derives fromBase
that definesoperator new
(what do I do about multiple inheritance?)::operator new
otherwise