I'm trying to implement a stack allocator that would work with std::vector. There are plenty of already existing implementations like this or this. However, all of them assume the buffer is not a member, but is provided to the allocator by the user. A comment in chromium's implementation even says that:
STL likes to make copies of allocators, so the allocator itself can't hold the data.
I tried myself and vector is crashing in its destructor. It seems that it creates a temporary version of my allocator for container proxy, allocates memory through that, and immediately destroys it, making a pointer to allocated data a dangling one.
Is it actually possible to have an allocator that stores a static buffer as a member?