Topic: Allocator instances (Was: basic_string and reference counting)


Author: Matt Austern <austern@sgi.com>
Date: 2000/05/26
Raw View
James Kuyper <kuyper@wizard.net> writes:

> The writers of the standard felt that there was insufficient experience
> with  allocators that allow inequivalent instances to justify
> standardizing them. However, they wanted to encourage further
> experimentation with the concept. Therefore, they allow but do not
> mandate standard containers that can work with such allocators. I would
> prefer that they were mandated, and would prefer the semantics of such
> containers to be defined by the standard, rather than being
> implementation-defined. However, I can understand the committee's
> hesitation, and therefore I'm only frustrated.
>
> Does anyone know if there's any implementation of the C++ standard
> library where the standard containers can handle such allocators?

Most implementations can, I suspect.  I know that both the SGI and the
Dinkumware implementations can handle allocators where different
instances are considered distinct, and I would guess that the other
popular implementations (e.g. Rogue Wave) can too.

If you look at the source code for SGI's open source IA-64 compiler
(http://oss.sgi.com/projects/Pro64/), you'll see that we even use
that functionality.  Look for the file mempool_allocator.h, in the
common/util directory.

The problem never was that anyone thought it was impossible to take
advantage of non-equivalent allocators, but rather that the semantics
would have to be specified.  For example, what happens when you write
v1.swap(v2) when v1 and v2 use different allocator instances?  The SGI
and Dinkumware implementations answer that question in slightly
different ways.

I expect that in a future revision of the standard, library
implementations will be required to have full support for allocators
where different instances may be considered distinct.  I don't
know whether the standard will use the SGI version, the Dinkumware
version, or something else.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]