title: Assert with dynamic message?
body: <p>In my program I want to use asserts that show an error message. Apart from the well known workarounds for C and C++ there's the "real" solution as BOOST offers <code>BOOST_ASSERT_MSG( expr, msg )</code> (see also <a href="https://stackoverflow.com/questions/5867834/assert-with-message">assert() with message</a>)</p>
  
  <p>But a static message isn't enough for me, I also want to show sometimes the failed variables, e.g. in a case like</p>
  
  <pre><code>BOOST_ASSERT_MSG( length &gt;= 0, "No positive length found! It is " &lt;&lt; length )
  </code></pre>
  
  <p>As you can see I'd like to format the message "string" as an <code>stringstream</code> or <code>ostream</code> as that'd allow me to easily show custom types (assuming I've defined the relevant formating function).</p>
  
  <p>The problem here is that <code>BOOST_ASSERT_MSG</code> is by default requiring a <code>char const *</code> so that's not compatible.</p>
  
  <p>Is there a way to redefine / overload <code>assertion_failed_msg()</code> in such a way that using a stream as message will work? How?<br>
  (My naive approach failed as the compiler first wanted to do an <code>operator&lt;&lt;("foo",bar)</code> on the message itself...)</p>