title: size() and capacity() of c++ vectors
body: <p>I've just started with C++'s standard library and the first thing I started with is <code>std::vector</code>. I've a bit of confusion with the <code>capacity()</code> in a  vector. I know that after each <code>push_back()</code>, the <code>capacity</code> of the vector changes in exponential powers, but in the below output the <code>capacity</code> remains the same value sometimes, even after insertions. Can someone kindly explain to me the internal working?</p>
  <pre><code>#include&lt;iostream&gt;
  #include&lt;vector&gt;
  
  using namespace std;
  
  int main(){
      vector&lt;int&gt; v;
      int capacity=v.capacity();
      cout&lt;&lt;&quot;Capacity before push_back(): &quot;&lt;&lt;capacity&lt;&lt;endl;
      for(int i=0;i&lt;10;i++){
          v.push_back(i);
          cout&lt;&lt;&quot;Capacity: &quot;&lt;&lt;v.capacity()&lt;&lt;endl;
          
      }
      for(auto j=v.begin();j!=v.end();j++){
          cout&lt;&lt;*j&lt;&lt;endl;
      }
       
      cout&lt;&lt;&quot;Size of vector: &quot;&lt;&lt;v.size()&lt;&lt;endl;
      cout&lt;&lt;&quot;Final Capacity of vector: &quot;&lt;&lt;v.capacity()&lt;&lt;endl;
      
      return 0;
  }
  </code></pre>
  <p>OUTPUT:</p>
  <pre><code>Capacity before push_back(): 0
  Capacity: 1
  Capacity: 2
  Capacity: 4
  Capacity: 4
  Capacity: 8
  Capacity: 8
  Capacity: 8
  Capacity: 8
  Capacity: 16
  Capacity: 16
  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
  Size of vector: 10
  Final Capacity of vector: 16
  </code></pre>