do allocators have to be stateless?





--
Is there a requirement for allocator to be stateless?

I need a std::set that will throw an exception when it's size reaches
some (run-time determined) size. Thought it would be just a simple
matter of providing allocator tracking how many items are already
allocated and throwing when the max is reached .

Unfortunately, the exception is being thrown from the default std::set
constructor, and allocator seems to be uninitialized... :(

The allocator in question is a copy of Josuttis's example with
current_size and max_size members added. Of course, they are
initialized in a constructor, which apparently is not being called.

Any thoughts?
.



Relevant Pages

  • Re: new keyword
    ... custom allocator and object cache. ... If you have lookaside list for memory blocks, you have a custom allocator. ... If an exception is thrown in the middle of constructor, ...
    (microsoft.public.vc.mfc)
  • Re: N1298 - try/finally for C
    ... Using a void*, or something containing a void*, gives ... Then we have a function that potentially throws an exception: ... If you mean some custom allocator, then we generally need to pass yet ... As for function pointers, and besides that throwing function pointers ...
    (comp.std.c)
  • Re: Pitfalls: Injecting an exception to another thread in the same pro
    ... what if I made my worker thread exception ... You're in the middle of the storage allocator. ... I don't even know what you mean by "inject an exception into a system function" because I ... it at a point where your context was in some weird state that could not be recovered ...
    (microsoft.public.vc.mfc)
  • Re: Allocators and exceptions
    ... If an exception raise occurs during the initialization ... and, in fact, there is no guarantee that you can even ... standard storage pool, ... The allocator itself won't raise any ...
    (comp.lang.ada)
  • Re: Vector and derived classes objects
    ... I've been mis-reading Josuttis and parts of the manual. ... google newsreader so I'm unsure if your or anyone else responded ... will use its allocator, and the allocator could throw an exception if ... and that function could throw an exception. ...
    (comp.lang.cpp)

Loading