This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: allocator construct() / destruct() behaviour...


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]