isAllocator

Tofu Ninja via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Dec 1 04:37:11 PST 2015


On Tuesday, 1 December 2015 at 08:58:56 UTC, BBaz wrote:
> I think that `is(CAllocatorImpl!Alloc)` should work too then.

According to the 'is' version, int is an allocator. No idea why 
it thinks this works...

enum isAllocator(Alloc) = is(CAllocatorImpl!Alloc);
static assert(isAllocator!int);

This seems to work well though...
enum isAllocator(Alloc) = __traits(compiles, {IAllocator alloc = 
new CAllocatorImpl!Alloc;});

static assert(isAllocator!Mallocator);
static assert(isAllocator!GCAllocator);
static assert(!isAllocator!int);


More information about the Digitalmars-d-learn mailing list