title: Is returning a C++ std::string object safe from memory leaks?
body: <p>I'm fairly novice with C++'s strings so the following pattern may be a little fugly.  I'm reviewing some code I've written before beginning integration testing with a larger system.  What I'd like to know is if it is safe, or if it would be prone to leaking memory?</p>
  
  <pre><code>string somefunc( void ) {
      string returnString;
      returnString.assign( "A string" );
      return returnString;
  }
  
  void anotherfunc( void ) {
      string myString;
      myString.assign( somefunc() );
      // ...
      return;
  }
  </code></pre>
  
  <p>The understanding I have is that the value of returnString is assigned to a new object myString and then the returnString object is destroyed as part of resolving the call to somefunc.  At some point in the future when myString goes out of scope, it too is destroyed.</p>
  
  <p>I would have typically passed a pointer to myString into somefunc() and directly assigned to values to myString but I'm striving to be a little clearer in my code ( and relying on the side effect function style less ).</p>