Absence of isAllocator trait
Paul Backus
snarwin at gmail.com
Mon Sep 6 15:46:52 UTC 2021
On Monday, 6 September 2021 at 13:24:56 UTC, Basile B. wrote:
> It's because the clients of an allocator should rather
> statically check for specific traits of an allocator, there are
> too many possible permutations of capabilities possible, not
> all can allocate and deallocate, not all can reallocate, and so
> on.
According to [the documentation][1], there are two required
properties all allocators must have:
* `uint alignment`
* `void allocate(size_t size)`
So it makes sense to have an `isAllocator` trait that checks for
those, even if clients are expected to check for other properties
individually.
[1]:
https://dlang.org/phobos/std_experimental_allocator_building_blocks.html
More information about the Digitalmars-d-learn
mailing list