Thread View: comp.std.c++
1 messages
1 total messages
Started by Niklas Smedberg
Wed, 29 Nov 1995 06:18
STL allocators
Author: Niklas Smedberg
Date: Wed, 29 Nov 1995 06:18
Date: Wed, 29 Nov 1995 06:18
35 lines
1785 bytes
1785 bytes
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. ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads