<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 <spanclass="RenoLink"><ahref="enable_current_exception.html">enable_current_exception</a></span> at the time of the throw is required in order to use cloning.</p>
<h4>Note:</h4>
<p>All exceptions emitted by the familiar function boost::<spanclass="RenoLink"><ahref="throw_exception.html">throw_exception</a></span> are guaranteed to derive from boost::<spanclass="RenoLink"><ahref="exception.html">exception</a></span> and to support cloning.</p>
<p>Of course, <spanclass="RenoLink"><ahref="enable_current_exception.html">enable_current_exception</a></span> may be used with any exception type; there is no requirement that it should derive from boost::<spanclass="RenoLink"><ahref="exception.html">exception</a></span>.</p>
<p>When you catch an exception, you can call <spanclass="RenoLink"><ahref="current_exception.html">current_exception</a></span> to get an <spanclass="RenoLink"><ahref="exception_ptr.html">exception_ptr</a></span> object:</p>
<p>In the above example, note that <spanclass="RenoLink"><ahref="current_exception.html">current_exception</a></span> captures the original type of the exception object. The exception can be thrown again using the <spanclass="RenoLink"><ahref="rethrow_exception.html">rethrow_exception</a></span> function:</p>
<p>Note that <spanclass="RenoLink"><ahref="current_exception.html">current_exception</a></span> 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 <spanclass="RenoLink"><ahref="exception_ptr.html">exception_ptr</a></span> points to an instance of std::bad_alloc, or</li>
<li> if <spanclass="RenoLink"><ahref="enable_current_exception.html">enable_current_exception</a></span> was not used in the throw-expression passed to the original throw statement and the current implementation does not have the necessary compiler-specific support to copy the exception automatically, in which case the returned <spanclass="RenoLink"><ahref="exception_ptr.html">exception_ptr</a></span> points to an instance of <spanclass="RenoLink"><ahref="unknown_exception.html">unknown_exception</a></span>.</li>
<p>Regardless, the use of <spanclass="RenoLink"><ahref="current_exception.html">current_exception</a></span> and <spanclass="RenoLink"><ahref="rethrow_exception.html">rethrow_exception</a></span> in the above examples is well-formed.</p>