title: Another c++ temporary lifetime confusion
body: <p>In the below code snippet...  is it safe to store a reference to the temporary string returned by <code>Quote::toXML</code> in <code>ToXML::s_</code> member variable, at least as long as it is used with the <code>&lt;&lt;</code> operator only?  I.e. is the result of the sub-expression <code>q.toXML</code> alive until the next <code>;</code>?</p>
  
  <p>And what is the full expression here w.r.t. the return value of <code>q.toXML</code>.  The entire <code>std::cout</code> or the call to <code>ToXML</code> constructor ?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  struct ToXML
  {
      ToXML(char const * const tag, std::string const &amp; s) : tag_(tag), s_(s)
      {
      }
  
      char const * tag_;
      std::string const &amp; s_;
  };
  
  std::ostream &amp; operator &lt;&lt; (std::ostream &amp; os, ToXML const &amp; v)
  {
      return os &lt;&lt; "&lt;" &lt;&lt; v.tag_ &lt;&lt; "&gt;" &lt;&lt; v.s_ &lt;&lt; "&lt;/" &lt;&lt; v.tag_ &lt;&lt; "&gt;";
  }
  
  struct Quote
  {
      std::string toXML() const
      {
          return "&lt;Quote/&gt;";
      }
  };
  
  int main()
  {
      Quote q;
      std::cout &lt;&lt; ToXML("quote", q.toXML()) &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>