title: Does const reference prolong the life of a temporary object returned by a temporary object?
body: <p>I know that const reference prolongs the life of a temporary locally. Now I am asking myself if this propriety can be extended on a chain of temporary objects, that is, if I can safely define:</p>
  
  <pre><code>std::string const&amp; foo = aBar.getTemporaryObject1().getTemporaryObject2();
  </code></pre>
  
  <p>My feeling is that, since the the first method <code>aBar.getTemporaryObject1()</code> returns already a temporary object, the propriety doesn't hold for <code>aBar.getTemporaryObject2()</code>.</p>