On 4/7/18 10:57 AM, Per Nordlöw wrote:
On Saturday, 7 April 2018 at 07:50:37 UTC, Eduard Staniloiu wrote:
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.
IMHO, such a complexity should be wrapped in a typed allocation layer.
Have Andrei spoken anything about `TypedAllocator`(s) to wrap this
complexity?
Well, you know the type, because make returned it no? The contract is,
you call obj = make!X(args), then you have to call dispose(obj), where
obj is of the type X. That's how it knows.
If you are thinking you want to destroy the whole block at once (typed
as void[]), that's not how it works.
stdx.allocator is not going to help you with GC collection, it's not
geared towards that purpose.
-Steve