title: Fill vector with true value
body: <p>i would like to make all the values in a <code>std::vector</code> <code>true</code>. I wrote 2 methods: the first one worked but the second did not. It tells me myproj.exe has triggered a breakpoint. Do you know what is the problem?</p>
  
  <p>This one works:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>void first(std::vector&lt;bool&gt;&amp; vect, unsigned int n) 
  {       
      for (unsigned int i = 0; i &lt; n; i++) 
      {       
          vect.push_back(true);
      }
  }
  </code></pre>
  
  <p>This one does not:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>void secound(std::vector&lt;bool&gt;&amp; vect, unsigned int n) 
  {       
      for(unsigned int i = 0; i &lt; n; i++) 
      {
          vect[i] = true; //crash here        
      }
  }
  </code></pre>