How do you declare and use an overloaded pool operator delete? How do you declare and use an overloaded pool operator delete? arrays arrays

How do you declare and use an overloaded pool operator delete?


Call the dtors on the individual objects first and then use:

for (int i = 0; i < 15; ++i) manyFoos[ i ]->~Foo();operator delete[] (manyFoos, pool);

You can read the whole FAQ item again and you will find it there.


It is impossible. Bjarne reasons that you'll never get it right figuring out the correct pool. His solution is: you must manually call all destructors and then figure out the correct pool to be able to deallocate the memory manually.

References:

Bjarne's FAQ: Is there a placement delete?

Relevant C++ standard sections:

3.7.3.2.2 Only member operator delete functions with an argument of size_t type are considered for delete expressions.

5.3.5.1 Delete expression syntax does not allow extra parameters.