Trying to make FreeList Allocator example compile

Nicholas Wilson iamthewilsonator at hotmail.com
Mon Oct 8 23:24:17 UTC 2018


On Monday, 8 October 2018 at 21:50:33 UTC, Per Nordlöw wrote:
> I'm trying to compile the example
>
>     import std.experimental.allocator.building_blocks.free_list 
> : FreeList;
>     theAllocator = allocatorObject(FreeList!8());
>
> at https://dlang.org/phobos/std_experimental_allocator.html but 
> fails first because of missing import
>
>     import std.experimental.allocator : allocatorObject, 
> theAllocator;
>
> and then, when adding this import, it fails again with the error
>
> /home/per/Work/knet/phobos-next/snippets/gctester.d(127,40): 
> Error: template instance `FreeList!8` does not match template 
> declaration `FreeList(ParentAllocator, ulong minSize, ulong 
> maxSize = minSize, Flag adaptive = No.adaptive)`
>
> Why is this example missing the `ParentAllocator` template 
> parameter and what is the preferred type for `ParentAllocator`?

ParentAllocator can be anything preferred types don't really make 
sense in a composable design, but it's probably best to go with 
something like GCAllocator, Mallocator, (Mmap, Sbrk etc.) 
something that asks the system for more memory for the last 
fallback so you don't run out of memory.



More information about the Digitalmars-d-learn mailing list