|
Subject: Re: allocator construct() / destruct() behaviour... Newsgroups: gmane.comp.gcc.libstdc++.devel Date: 2004-07-19 21:28:49 GMT (4 years, 24 weeks, 6 days and 42 minutes ago) On Jul 19, 2004, at 9:25 AM, pippadav <at> 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 |
|
|