title: C++ return value optimization, multiple unnamed returns
body: <p>Let's consider these two functions :</p>
  
  <pre><code>// 1. Multiple returns of the same named object
  string f() {
      string s;
      if (something())
          return s.assign(get_value1());
      else
          return s.assign(get_value2());
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>// 2. Multiple returns, all of unnamed objects
  string g() {
      if (something())
          return get_value1();
      else
          return get_value2();
  }
  </code></pre>
  
  <p>How each of these functions will actually behave in terms of RVO is of course compiler-dependent. Am I right, however, to assume that RVO for both of them is common ?</p>
  
  <hr>
  
  <p><em>p.s.</em> (See answers) Function #1 was intended to be the following:</p>
  
  <pre><code>string f() {
      string s;
      if (something())
          return s;
      s.assign(get_value());
      return s;
  }
  </code></pre>