Topic: STL allocators


Author: d91-sme@nada.kth.se (Niklas Smedberg)
Date: 1995/11/29
Raw View
Why isn't an STL allocator a complete class, but a mix of member
functions and global functions (like the important construct and
destroy functions)?

I can see that it's now easier for example to add different kinds
of constructs and destroys, but wouldn't it be as easy to just
derive a new allocator class with these differencies?

As I figure, the STL containers can use only one and same allocator.
Why? Wouldn't it be neat if you could specify a different allocator
for one instance of vector<T *> that handled destruction of the
actual object, not just the pointer? Then you wouldn't have to write
new container classes that dealt with ownership of pointers, and it
would also be much more efficient than using "smart pointer classes".

Because destroy() is a global function (and there can be only one
destroy(MyClass *) function), I can't use it as I want. I only want
destroy() to "own" my pointers to MyClass when I store them in a
_few_ containers, not _all_ of them.

Has anybody else thought of this? (Especially in the C++ committee)

/Smedis
--
                   __\/__
                  / ^  _ \
               (\| (o)(o) |/)
+-----------.OOOo----oo----oOOO.---------------------------------------+


---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]