limit the growth of a vector in c++
c++, vector
Solution
Sort of. You can write a custom allocator and use it in a `std::vector` (the second template argument of the vector). The allocator needs to satisfy these requirements. However, doing this properly isn't simple. And your `vector` wouldn't just ignore `push_back` after the max size was met, it would throw.
Problem
Is it possible to limit the `vector.max_size()` in order to limit the growth of a vector? If not, is having a function to watch the `vector.capacity()` to ensure it doesn't go over a determined amount a viable substitute?