Vector - if vec.size() == vec.max_size()

Since vector double it’s size when it gets full and reallocates it’s elements to the new memory location. What happens if there is no more space for the vector to do reallocation i.e. the vec.size() equals to vec.max_size() ?
Will it give some error?

Hey Bhawna, it is a rare case though if vec.size()==vec.max_size() it will give an error that memory is full and you can’t add more elements to the vector. But vec.max_size() is the maximum potential size the container can reach due to known system or library implementation limitations, but the container is by no means guaranteed to be able to reach that size: it can still fail to allocate storage at any point before that size is reached.

My understanding was the same but couldn’t find any proof/reference. Thanks Sanjeet.