title: Is there any danger related to streaming data into a c++ exception class?
body: <p>Please consider the following code:</p>
  
  <pre><code>throw my_exception() &lt;&lt; "The error " &lt;&lt; error_code &lt;&lt; " happened because of " &lt;&lt; reasons;
  </code></pre>
  
  <p>The supporting code would be something like:</p>
  
  <pre><code>class my_exception
  {
     public:
        template &lt;typename T&gt;
        my_exception &amp; operator &lt;&lt; (const T &amp; value)
        {
           // put the value somewhere
           return *this;
        }
        // etc.
  };
  </code></pre>
  
  <p>Is there any reason that would make such <code>throw</code> dangerous, or simply inefficient compared to the alternative below?</p>
  
  <pre><code>std::stringstream s;
  s &lt;&lt; "The error " &lt;&lt; error_code &lt;&lt; " happened because of " &lt;&lt; reasons;
  throw my_exception(s.str());
  </code></pre>