title: Faster to swap or assign a vector of strings?
body: <p>I have a class with a vector of strings and a function that assigns to that vector. I am changing my function to only assign to the vector if it's successful. To do that I use a temporary vector of strings in the function and then if the function is successful I assign to the vector of strings in the class.</p>
  <p>For example:</p>
  <pre><code>class test
  {
      vector&lt;string&gt; v;
      void Function()
      {
          vector&lt;string&gt; temp;
          v = temp; // Is this better?
          v.swap( temp ); // Or instead is this better?
      }
  };
  </code></pre>