Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > media > main-release > by-pkgid > bd29e346140bd3fbcbf1674e576e565a > files > 414

libsigc++2.0-doc-2.2.7-1mdv2010.1.x86_64.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>libsigc++: exception_catch()</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>exception_catch()<br/>
<small>
[<a class="el" href="group__adaptors.html">Adaptors</a>]</small>
</h1>
<p>sigc::exception_catch() catches an exception thrown from within the wrapped functor and directs it to a catcher functor. <a href="#_details">More...</a></p>
<table border="0" cellpadding="0" cellspacing="0">
</table>
<p>sigc::exception_catch() catches an exception thrown from within the wrapped functor and directs it to a catcher functor. </p>
<p>This catcher can then rethrow the exception and catch it with the proper type.</p>
<p>Note that the catcher is expected to return the same type as the wrapped functor so that normal flow can continue.</p>
<p>Catchers can be cascaded to catch multiple types because uncaught rethrown exceptions proceed to the next catcher adaptor.</p>
<dl class="user"><dt><b>Examples:</b></dt><dd><div class="fragment"><pre class="fragment"> <span class="keyword">struct </span>my_catch
   {
     <span class="keywordtype">int</span> operator()()
     {
       <span class="keywordflow">try</span> { <span class="keywordflow">throw</span>; }
       <span class="keywordflow">catch</span> (<a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00639.html">std::range_error</a> e) <span class="comment">// catch what types we know</span>
         { <a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01116.html#a7431d56d1e8cd7a9b854171294bd71c7">std::cerr</a> &lt;&lt; <span class="stringliteral">&quot;caught &quot;</span> &lt;&lt; e.<a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00669.html#ae3ab99c81fd42c6d1db9d9e42b3eddde">what</a>() &lt;&lt; <a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01116.html#a75c5d34c6c0dcd2c1a01307dbf6ad8c5">std::endl</a>; }
       <span class="keywordflow">return</span> 1;
     }
   }
   <span class="keywordtype">int</span> foo(); <span class="comment">// throws std::range_error</span>
   sigc::exception_catch(&amp;foo, my_catch())();
</pre></div></dd></dl>
<p>The functor sigc::execption_catch() returns can be passed into <a class="el" href="classsigc_1_1signal7.html#adc55ac9b0f935fd87a67904022e03cb2" title="Add a slot to the list of slots.">sigc::signal::connect()</a> directly.</p>
<dl class="user"><dt><b>Example:</b></dt><dd><div class="fragment"><pre class="fragment"> <a class="code" href="classsigc_1_1signal.html" title="Convenience wrapper for the numbered sigc::signal# templates.">sigc::signal&lt;int&gt;</a> some_signal;
   some_signal.<a class="code" href="classsigc_1_1signal7.html#adc55ac9b0f935fd87a67904022e03cb2" title="Add a slot to the list of slots.">connect</a>(sigc::exception_catch(&amp;foo, my_catch));
</pre></div> </dd></dl>
</div>
<hr size="1"/><address style="text-align: right;"><small>Generated on Tue May 4 21:44:39 2010 for libsigc++ by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>
</html>