Prior to C ++ 11, STL implementations were allowed to require distributors to behave somehow stagnant.
“acting as if stateless” means that the STL can count on the following:
MyAllocator a1; void * p = a1.allocate(77, 0); MyAllocator a2; a2.free(p);
(IIRC, this simplifies the implementation of some container operations.)
"was allowed to require" means that the STL implementation can support state locks (like yours), but not necessary.
C ++ 11 requires stateful generator support.
I could not, however, find a brief introduction to this (does anyone want to add this?) This thread may give you some links .
If you are tied to a specific compiler that does not support distributed resources with state support, you have some not-so-brilliant options:
- includes a reference to your state as an argument to the dispenser pattern
- in your distribution, include a backlink to the appropriate allocator (usually destroys the assignment of a custom allocator for small data)
source share