On Friday, 6 April 2018 at 21:49:37 UTC, Per Nordlöw wrote:
On Tuesday, 3 April 2018 at 09:14:28 UTC, Eduard Staniloiu
wrote:
So, say `reg` is your allocator, your workflow would be
auto obj = reg.make!Type(args);
/* do stuff */
reg.dispose(obj); // If Type has a __dtor, it will call
obj.__dtor
// and then reg.deallocate(obj)
If I do sucessive calls to reg.make!X where X are different
kinds of classes of different sizes how does reg.dispose(obj)
figure out at which address(es) (where emplace filled in the
data) the objects reside?
It can't figure out. With custom allocators you have to manually
do
the memory management, so the responsibility of when and which
object needs
to be destroyed falls on the user of the custom allocator.