Proposal for std::vector.

Matt Austern austern@apple.com
Fri Feb 6 18:56:00 GMT 2004


On Feb 6, 2004, at 4:51 AM, Dhruv Matani wrote:

> The relevant discussion can be found by searching google for:
> About std::vector and standard containers in general.
>
>
> Wierd as it may seem, are standard containers such as std::vector
> allowed
> to derive from std::allocator, or more generally from an allocator
> class?
>
> Mainly used to make use of EBO in case of an empty allocator such as
> new_allocator and malloc_allocator.
>
>
>
> I liked a solution that one poster mentioned about having an IMPL class
> within vector. So something like this:
>
>
> template <T, A>
> class vector {
>    template <_A>
>    struct IMPL : public _A {
>       _M_start, _M_finish, etc...
>    };
> };
>
>
> What do you think about it? Can it be merged with the library?

Right now, in our implementation, the standard containers *do*
inherit from allocators.  I can't think of any reason why it would
be prohibited.  It's only prohibited if it would cause some
conforming program to fail, and I can't think of any.

Your IMPL technique would work too, but it's more complicated
and I don't really see much benefit to justify the extra work.
What do you see as the advantages?

			--Matt




More information about the Libstdc++ mailing list