title: bad_alloc while initializing and filling a vector?
body: <p>While trying to generate a vector of random numbers I stumble across a std::bad_alloc error. Here's my code:</p>
  
  <pre><code>#include "search.h"
  #include "gtest/gtest.h"
  
  int _size = 100;
  
  std::vector&lt;int&gt; GetSortedVector(int size){
      //init vector
      std::vector&lt;int&gt; v(size);
      //fill with random numbers
      for (std::vector&lt;int&gt;::size_type i=0; i &lt; v.size(); i++)
          v.push_back( std::rand()%(2*size) );
      //return the setup vector
      return v;
  }
  
  //triggered automatically
  TEST(BinarySearch, NonUniqueSorted){
      std::vector&lt;int&gt; v = GetSortedVector(_size);//nothing moves farther than this line
  }
  </code></pre>
  
  <p><strong>P.S.:</strong> I do use <code>generate()</code> by now, but am still curious why it failed.</p>