what is the capacity of an empty vector?

c++, stl, vector

Solution

C++ Standard 23.2.4.2 only says that `vector::capacity` is

The total number of elements that the vector can hold without requiring reallocation.

That means that the actual value is fully implementation specific.

Problem

Looks like a stupid question. But comment to my answer to one of the SO question made me to think again. [ comment says, capacity need not be zero for empty vector] By default my answer would be 0 as there are no elements inside vector. It makes sense to keep the capacity as 0 and on the first allocation it can be increased without any performance hits. But standard does not say anything one this. ( I checked in Josuttis book as well). Is it purely implementation specific? Does any STL vendor use some arbitrary number as capcity for the empty vector? Any thoughts...

Original source