I was just answering a question about the lack of placement delete corresponding to placement new. The reason seems to be the way operator delete
is called according to the dynamic type of the object (corresponding to the type used to find operator new
).
Placement new
has been useful to me. When it comes to custom allocation, there is probably a reusable class where different instances manage different pools. Singletons are an anti-pattern and all that.
I can understand the convenience of making new thing;
work without keeping track of an allocator, but doing things for different branches of the type hierarchy seems pretty convoluted.
Is there a real-world scenario where a derived class uses a different allocator from its base, and relies on a virtual destructor to find the correct member operator delete
?
Lest this be subjective, I'll accept the answer which is most plausible. Let's not quibble over code smells or the "best" way of doing things.