On 2017-03-28 19:09, 'Walt Karas' via ISO C++ Standard - Future
Proposals wrote:
>
>
> On Tuesday, March 28, 2017 at 12:26:13 PM UTC-4, Thiago Macieira wrote:
>
> On terça-feira, 28 de março de 2017 07:05:29 PDT 'Walt Karas' via
> ISO C++
> Standard - Future Proposals wrote:
> > Specifcally, should it be: template <typename, size_t> class
> allocator
> >
> > The size_t parameter is the fixed size of each allocation.
>
> What is the fixed size of each allocation for the containers?
> std::vector (for
> example) does not have a fixed size allocation..
>
> --
>
>
> Thiago Macieira - thiago (AT)
macieira.info <
http://macieira.info> -
> thiago (AT)
kde.org <
http://kde.org>
> Software Architect - Intel Open Source Technology Center
>
>
> OK, that's a good point. So it seems a better strategy that the
> allocator remain a class parameter, but be required to have the public
> members:
>
> template <size_t> pointer fixed_size_alloc();
> template <size_t> void fixed_size_dealloc(pointer p);
>
> (Except that, for reasons I don't understand, allocate/deallocate
> currently use T* rather then pointer for the raw memory pointers.)
>
> One could write short definitions of these that simply call allocate and
> deallocate if no optimization for certain constant sizes was useful.
>
Can't we just have a node_allocator<T> and use that with std::list? Then
we can have that allocator assume that it will **always** be called with
allocate(1), and optimize for that.
Bo Persson