isAllocator

BBaz via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Dec 1 00:58:54 PST 2015


On Tuesday, 1 December 2015 at 03:05:34 UTC, Rikki Cattermole 
wrote:
> On 01/12/15 3:23 AM, Tofu Ninja wrote:
>> On Monday, 30 November 2015 at 14:21:49 UTC, Tofu Ninja wrote:
>>> Is there something like isInputRange for allocators, I tried 
>>> looking
>>> for something but couldn't find anything? If not, why not?
>>
>> Aka, some way to check that type T is an allocator.
>
> Doesn't look like it.
>
> bool isAllocator(Alloc)() pure {
> 	return __traits(compiles, {IAllocator alloc = new 
> CAllocatorImpl!Alloc;});
> }
>
> That should work however.

I think that `is(CAllocatorImpl!Alloc)` should work too then.


More information about the Digitalmars-d-learn mailing list