title: Why does vector initialization constructs and copies?
body: <p>I am learning C++ and I have been looking at STL containers. I have many questions but I think this can go first. Consider this class and vector of it.</p>
  
  <pre><code>class A {
     int i;
     // A(const A&amp;);
  public:
  
     A(int i) : i(i) {cout &lt;&lt; "consting " &lt;&lt; i &lt;&lt; endl;}
     A(const A&amp; ot) : i(ot.i) {cout &lt;&lt; "copying " &lt;&lt; i &lt;&lt; endl;}
  
  };
  
  int main () {
     vector&lt;A&gt; v1 = {A(1),A(2),A(3),A(4)};
     vector&lt;A&gt; v2(1,A(5));
     vector&lt;A&gt; v3;
     v3.push_back(A(6));
  }
  </code></pre>
  
  <p>gives me the output</p>
  
  <pre><code>consting 1
  consting 2
  consting 3
  consting 4
  copying 1
  copying 2
  copying 3
  copying 4
  consting 5
  copying 5
  consting 6
  copying 6
  </code></pre>
  
  <p>Clearly it is constructing and copying each <code>A</code>. </p>
  
  <p>Is there some way of preventing this. What I mean is how can I avoid the extra copy and just construct <code>A</code> into the vector. Is this posssible. If not can someone explain why? Thank you. </p>
  
  <p>EDIT: 
  Just for completion's sake <code>push_back</code> does the same</p>