This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: allocator construct() / destruct() behaviour...
- From: Matt Austern <austern at apple dot com>
- To: pippadav at dei dot unipd dot it
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Mon, 19 Jul 2004 14:28:49 -0700
- Subject: Re: allocator construct() / destruct() behaviour...
- References: <1090254326.40fbf5f6420a8@mail.dei.unipd.it>
On Jul 19, 2004, at 9:25 AM, pippadav@dei.unipd.it wrote:
Hi everybody !
There's a behaviour in STL allocator I don't understand, I hope
somebody can
help me...
I'm trying to customize an allocator to track the insertion/deletion
of objects
in a container,
decorating the standard allocator functions construct() and destroy().
The problem is that it seems that those functions are never called in
STL
containers, instead
a global template function _Construct() (defined in <stl_construct.h>)
is
called, that is
completely unaware of allocators.
This is a bug. I thought it had been fixed long ago, but I see it
wasn't.
If people are interested in a fix (for mainline, of course), I can come
up with one pretty quickly. The basic idea: don't use any of the
std::uninitialized_* functions. In a world with stateful allocators,
all of them are useless. Instead define our own functions that are
just like them but that take an additional argument for the allocator,
and that use the allocator's construct and destroy member functions.
This fix will touch a fair number of lines of code, but it's pretty
mechanical.
--Matt