why allocators are not discussed here

Dmitry Olshansky dmitry.olsh at gmail.com
Wed Jun 26 08:28:09 PDT 2013


26-Jun-2013 05:24, Adam D. Ruppe пишет:
> I was just quickly skimming some criticism of C++ allocators, since my
> thought here is similar to what they do. On one hand, maybe D can do it
> right by tweaking C++'s design rather than discarding it.
>

Criticisms are:

A) Was defined to not have any state (as noted in the standard)
B) Parametrized on type (T) yet a container that is parametrized on it 
may need to allocate something else completely (a node with T).
C) Containers are parametrized on allocators so say 2 lists with 
different allocators are incompatible in a sense that e.g. you can't 
splice pieces of  them together.

Of the above IMHO we can deduce that
a) Should support stateful allocators but we have to make sure we don't 
pay storage space for state-less ones (global ones e.g. mallocator).
b) Should preferably be typeless and let container define what they allocate
c) Hardly solvable unless we require a way to reassign objects between 
allocators (at least of similar kinds)

>
> Anyway, bottom line is I don't think that criticism necessarily applies
> to D. But there's surely many others and I'm more or less a n00b re
> c++'s allocators so idk yet.


-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list