std.allocator needs your help

Johannes Pfau nospam at example.com
Mon Sep 23 09:25:44 PDT 2013


Am Tue, 24 Sep 2013 00:50:02 +1000
schrieb Manu <turkeyman at gmail.com>:

> [...] It also screws with generic code; X should be allocated with
> 'new', but Y should be allocated with yAllocator.alloc()?
> What if you decide that Z, which allocates with 'new', becomes a
> problem and you want to switch it into a pool? You now need to track
> down every instance of 'new Z', and change it.

That's not a problem with the proposed GC allocator. We should add
proper overloads to emplace and a "create" function and then all
code should use create!(Allocator, MyClass)(args) or
create!MyClass(allocatorInstance, args).

New should then be considered as deprecated and replaced by
create!(GCAllocator, Class)().


More information about the Digitalmars-d mailing list