TL;DR, you are trying to use the wrong container.
The allocator is responsible for the allocation, deallocation etc. of the memory as required by the container. It is the responsibility of the container to implement the required semantics and it uses the allocators to assist it in doing so.
std::vector
is probably not the best choice for the cache you describe, or at least not in its raw form.
You can look to boost (circular_buffer
) as an alternative.
Given the vector
you mention, you could also look to wrap that with the cache interface you desire, but changing the allocator is not the correct route. Changes to the allocator will leave the vector thinking there are valid objects in the "lower" 25% of the container, whilst the allocator has already removed them (or the memory to them).