title: How does std::vector's copy constructor operate?
body: <p>How does a <code>std::vector&lt;std::string&gt;</code> initialize its self when the following code is invoked</p>
  
  <pre><code>std::vector&lt;std::string&gt; original;
  std::vector&lt;std::string&gt; newVector = original;
  </code></pre>
  
  <p>It would seem as if the copy constructor would be invoked on <code>std::vector&lt;std::string&gt; new</code> during <code>newVector = original</code>, but how are the <code>std::string</code>'s brought over inside of the <code>orginal</code>? Are they copies or new <code>std::string</code>'s? So is the memory in <code>newVector[0]</code> the same as <code>original[0]</code>.</p>
  
  <p>The reason I ask is say I do the following</p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;string&gt;
  using namespace std;
  
  vector&lt;string&gt; globalVector;
  
  void Initialize() {
      globalVector.push_back("One");
      globalVector.push_back("Two");
  }
  
  void DoStuff() {
      vector&lt;string&gt; t = globalVector;
  }
  
  int main(void) {
      Initialize();
      DoStuff();
  }
  </code></pre>
  
  <p><code>t</code> will fall out of scope of <code>DoStuff</code> (on a non optimized build), but if it <code>t</code> is just filled with pointers to the <code>std::string</code>'s in <code>globalVector</code>, might the destructor be called and the memory used in <code>std::string</code> deleted, there for making <code>globalVector[0]</code> filled with garbage <code>std::string</code>'s after <code>DoStuff</code> is called?</p>
  
  <p>A nut shell, I am basically asking, when <code>std::vector</code>'s copy constructor is called, how are the elements inside copied?</p>