Worst thing that can happen if I don’t obey the dogma of arbitrary stateless switchgear?

I need to create my own dispenser for std :: objects (especially and originally for std :: vector), but in the end it can use other

The reason I need to create my own distributor is because I need to track allocated resources (heaps and stacks) by individual application components (this is an integral feature of the application). I will need a custom allocator to control the heap of resources, so it is very important that I can pass something like

trackerId idToTrackUsage;
myAlloca<int> allocator(idToTrackUsage);
vector<int> Foo( allocator );

However, after reading a little, I found this little bomb about the STL / C ++ standard (see links), which says that all instances of a dispenser of a given type should be equivalent (this means that == should return true for any two instances ) and, most terminals; any allocator should be able to free memory allocated by any other instance (that is, not having a way to find out what this other instance might be). In short, dispensers cannot have a state.

So, I'm trying to find a better way around this. Any smart ideas? I really really REALLY don't want to keep the custom version of std :: vector around.

EDIT: ++ 0x http://www2.research.att.com/~bs/C++0xFAQ.html#scoped-allocator, , . - , ++ 0x ,

:

Allocator ++

Google

+5
4

( " , undefined, " ), , , , , vector , " " :

vector(const Allocator &youralloc = Allocator()) {
    const Allocator hawhaw;
    // use hawhaw and ignore youralloc. 
    // They're interchangeable, remember?
}

, GCC (, , SGI- STL) -, , , .

, , , - , , , . , , , , . , .

, , .

+5

, , , . , , , .

+3

, . , , , .

+1

: , ++ 0x ++ 11, .

+1

All Articles