<p>Boost Exception supports transporting of exception objects between threads through cloning. This system is similar to <spanclass="RenoLink"><ahref="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2179.html">N2179</a></span>, but because Boost Exception can not rely on language support, the use of <tt><spanclass="RenoLink"><ahref="enable_current_exception.html">enable_current_exception</a></span>()</tt> at the time of the throw is required in order to use cloning.</p>
<p>All exceptions emitted by the familiar function <tt>boost::<spanclass="RenoLink"><ahref="throw_exception.html">throw_exception</a></span>()</tt> are guaranteed to derive from <tt>boost::<spanclass="RenoLink"><ahref="exception.html">exception</a></span></tt> and to support cloning.</p>
<p>When you catch a <tt>boost::<spanclass="RenoLink"><ahref="exception.html">exception</a></span></tt>, you can call <tt><spanclass="RenoLink"><ahref="current_exception.html">current_exception</a></span>()</tt> to get an <tt><spanclass="RenoLink"><ahref="exception_ptr.html">exception_ptr</a></span></tt> object:</p>
<p>In the above example, note that <tt><spanclass="RenoLink"><ahref="current_exception.html">current_exception</a></span>()</tt> captures the original type of the exception object, even though <tt>e</tt> refers to the base type <tt>boost::<spanclass="RenoLink"><ahref="exception.html">exception</a></span></tt>. This original type can be thrown again using the <tt><spanclass="RenoLink"><ahref="rethrow_exception.html">rethrow_exception</a></span>()</tt> function:</p>
<p><tt><spanclass="RenoLink"><ahref="current_exception.html">Clone_exception</a></span>()</tt> could fail to copy the original exception object in the following cases:</p>
<div><ul><li> if there is not enough memory, in which case the returned <tt><spanclass="RenoLink"><ahref="exception_ptr.html">exception_ptr</a></span></tt> points to an instance of <tt>std::bad_alloc</tt>, or</li>
<li> if <tt><spanclass="RenoLink"><ahref="enable_current_exception.html">enable_current_exception</a></span>()</tt> was not used in the throw-expression passed to the original <tt>throw</tt> statement, in which case the returned <tt><spanclass="RenoLink"><ahref="exception_ptr.html">exception_ptr</a></span></tt> points to an instance of <tt><spanclass="RenoLink"><ahref="unknown_exception.html">unknown_exception</a></span></tt>.</li>
<p>Regardless, the use of <tt><spanclass="RenoLink"><ahref="current_exception.html">current_exception</a></span>()</tt> and <tt><spanclass="RenoLink"><ahref="rethrow_exception.html">rethrow_exception</a></span>()</tt> in the above examples is well-formed.</p>