title: C++ cost of default constructors for string, list, vector
body: <p>In many cases I would like to pass reference to const string parameter with default being empty string.</p>
  
  <pre><code>void func(std::string const&amp; z = std::string());
  </code></pre>
  
  <p>I am wondering how expensive is calling default constructor vs. passing reference to some static empty string?</p>
  
  <pre><code>void func(std::string const&amp; z = my_staticEmptyStr);
  </code></pre>
  
  <p>What about lists and vectors?</p>
  
  <p>Update. Unfortunately, I do not see a nice generic way to have static empty-xxx objects, except having its own copy in every class that needs it. Fortunately, it seems to me that none of the default constructors for stl classes require memory allocations, so I decided to do it in a traditional way on all paths except frequently called ones.</p>