C++ allows overloading operator new
- both global and per-class - usual operator new
, operator new[]
used with new[]
statement and placement operator new
separately.
The former two of those three are usually overloaded for using customized allocators and adding tracing. But placement operator new
seems pretty straightforward - it actually does nothing inside. For example, in Visual C++ the default implementation just returns the address passed into the call:
//from new.h
inline void* operator new( size_t, void* where )
{
return where;
}
What else could it do? Why and how could I sensibly overload placement operator new
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…