Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-release > by-pkgid > 1594165b156266e3a745f0375fa80832 > files > 417

libsigc++2.0-doc-2.4.0-3.mga5.noarch.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"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.7"/>
<title>libsigc++: exception_catch()</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen-extra.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">libsigc++
   &#160;<span id="projectnumber">2.4.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.7 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</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><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">exception_catch()<div class="ingroups"><a class="el" href="group__adaptors.html">Adaptors</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p><a class="el" href="namespacesigc.html#a0ae3b8a1ba26920cee4d7d9df2c39ed9">sigc::exception_catch()</a> catches an exception thrown from within the wrapped functor and directs it to a catcher functor.  
<a href="#details">More...</a></p>
<p><a class="el" href="namespacesigc.html#a0ae3b8a1ba26920cee4d7d9df2c39ed9">sigc::exception_catch()</a> 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="section user"><dt>Examples:</dt><dd><div class="fragment"><div class="line"><span class="keyword">struct </span>my_catch</div>
<div class="line">{</div>
<div class="line">  <span class="keywordtype">int</span> operator()()</div>
<div class="line">  {</div>
<div class="line">    <span class="keywordflow">try</span> { <span class="keywordflow">throw</span>; }</div>
<div class="line">    <span class="keywordflow">catch</span> (<a class="codeRef" doxygen="/opt/gnome/share/mm-common/doctags/libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00900.html">std::range_error</a> e) <span class="comment">// catch what types we know</span></div>
<div class="line">      { std::cerr &lt;&lt; <span class="stringliteral">&quot;caught &quot;</span> &lt;&lt; e.what() &lt;&lt; <a class="codeRef" doxygen="/opt/gnome/share/mm-common/doctags/libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01616.html#a8b3758bb8f17c440c7963363f42f69f3">std::endl</a>; }</div>
<div class="line">    <span class="keywordflow">return</span> 1;</div>
<div class="line">  }</div>
<div class="line">}</div>
<div class="line"><span class="keywordtype">int</span> foo(); <span class="comment">// throws std::range_error</span></div>
<div class="line"><a class="code" href="namespacesigc.html#a0ae3b8a1ba26920cee4d7d9df2c39ed9">sigc::exception_catch</a>(&amp;foo, my_catch())();</div>
</div><!-- fragment --></dd></dl>
<p>The functor <a class="el" href="namespacesigc.html#a0ae3b8a1ba26920cee4d7d9df2c39ed9">sigc::exception_catch()</a> returns can be directly passed into <a class="el" href="classsigc_1_1signal7.html#adc55ac9b0f935fd87a67904022e03cb2" title="Add a slot to the list of slots. ">sigc::signal::connect()</a>.</p>
<dl class="section user"><dt>Example:</dt><dd><div class="fragment"><div class="line"><a class="code" href="classsigc_1_1signal.html">sigc::signal&lt;int&gt;</a> some_signal;</div>
<div class="line">some_signal.<a class="code" href="classsigc_1_1signal7.html#adc55ac9b0f935fd87a67904022e03cb2">connect</a>(<a class="code" href="namespacesigc.html#a0ae3b8a1ba26920cee4d7d9df2c39ed9">sigc::exception_catch</a>(&amp;foo, my_catch));</div>
</div><!-- fragment --> </dd></dl>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Mon Sep 15 2014 15:59:58 for libsigc++ by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.7
</small></address>
</body>
</html>