]> git.tdb.fi Git - ext/sigc++-2.0.git/blob - untracked/docs/reference/html/group__exception__catch.html
Import libsigc++ 2.10.8 sources
[ext/sigc++-2.0.git] / untracked / docs / reference / html / group__exception__catch.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5 <meta http-equiv="X-UA-Compatible" content="IE=9"/>
6 <meta name="generator" content="Doxygen 1.9.1"/>
7 <meta name="viewport" content="width=device-width, initial-scale=1"/>
8 <title>libsigc++: exception_catch()</title>
9 <link href="tabs.css" rel="stylesheet" type="text/css"/>
10 <script type="text/javascript" src="jquery.js"></script>
11 <script type="text/javascript" src="dynsections.js"></script>
12 <link href="doxygen.css" rel="stylesheet" type="text/css" />
13 <link href="doxygen-extra.css" rel="stylesheet" type="text/css"/>
14 </head>
15 <body>
16 <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
17 <div id="titlearea">
18 <table cellspacing="0" cellpadding="0">
19  <tbody>
20  <tr style="height: 56px;">
21   <td id="projectalign" style="padding-left: 0.5em;">
22    <div id="projectname">libsigc++
23    &#160;<span id="projectnumber">2.10.8</span>
24    </div>
25   </td>
26  </tr>
27  </tbody>
28 </table>
29 </div>
30 <!-- end header part -->
31 <!-- Generated by Doxygen 1.9.1 -->
32 <script type="text/javascript" src="menudata.js"></script>
33 <script type="text/javascript" src="menu.js"></script>
34 <script type="text/javascript">
35 /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
36 $(function() {
37   initMenu('',false,false,'search.php','Search');
38 });
39 /* @license-end */</script>
40 <div id="main-nav"></div>
41 </div><!-- top -->
42 <div class="header">
43   <div class="headertitle">
44 <div class="title">exception_catch()<div class="ingroups"><a class="el" href="group__adaptors.html">Adaptors</a></div></div>  </div>
45 </div><!--header-->
46 <div class="contents">
47
48 <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.  
49 </p>
50 <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>
51 <p>This catcher can then rethrow the exception and catch it with the proper type.</p>
52 <p>Note that the catcher is expected to return the same type as the wrapped functor so that normal flow can continue.</p>
53 <p>Catchers can be cascaded to catch multiple types, because uncaught rethrown exceptions proceed to the next catcher adaptor.</p>
54 <dl class="section user"><dt>Examples:</dt><dd><div class="fragment"><div class="line"><span class="keyword">struct </span>my_catch</div>
55 <div class="line">{</div>
56 <div class="line">  <span class="keywordtype">int</span> operator()()</div>
57 <div class="line">  {</div>
58 <div class="line">    <span class="keywordflow">try</span> { <span class="keywordflow">throw</span>; }</div>
59 <div class="line">    <span class="keywordflow">catch</span> (<a class="codeRef" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a02969.html">std::range_error</a> e) <span class="comment">// catch what types we know</span></div>
60 <div class="line">      { <a class="codeRef" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01635.html#a7431d56d1e8cd7a9b854171294bd71c7">std::cerr</a> &lt;&lt; <span class="stringliteral">&quot;caught &quot;</span> &lt;&lt; e.<a class="codeRef" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a02965.html#a45f5b9c4b7141ac429bf6ea99a7ff6bf">what</a>() &lt;&lt; <a class="codeRef" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01635.html#a8b3758bb8f17c440c7963363f42f69f3">std::endl</a>; }</div>
61 <div class="line">    <span class="keywordflow">return</span> 1;</div>
62 <div class="line">  }</div>
63 <div class="line">}</div>
64 <div class="line"><span class="keywordtype">int</span> foo(); <span class="comment">// throws std::range_error</span></div>
65 <div class="line"><a class="code" href="namespacesigc.html#a0ae3b8a1ba26920cee4d7d9df2c39ed9">sigc::exception_catch</a>(&amp;foo, my_catch())();</div>
66 <div class="ttc" id="aa01635_html_a7431d56d1e8cd7a9b854171294bd71c7"><div class="ttname"><a href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01635.html#a7431d56d1e8cd7a9b854171294bd71c7">std::cerr</a></div><div class="ttdeci">ostream cerr</div></div>
67 <div class="ttc" id="aa01635_html_a8b3758bb8f17c440c7963363f42f69f3"><div class="ttname"><a href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01635.html#a8b3758bb8f17c440c7963363f42f69f3">std::endl</a></div><div class="ttdeci">basic_ostream&lt; _CharT, _Traits &gt; &amp; endl(basic_ostream&lt; _CharT, _Traits &gt; &amp;__os)</div></div>
68 <div class="ttc" id="aa02965_html_a45f5b9c4b7141ac429bf6ea99a7ff6bf"><div class="ttname"><a href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a02965.html#a45f5b9c4b7141ac429bf6ea99a7ff6bf">std::range_error::what</a></div><div class="ttdeci">virtual const char * what() const noexcept</div></div>
69 <div class="ttc" id="aa02969_html"><div class="ttname"><a href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a02969.html">std::range_error</a></div></div>
70 <div class="ttc" id="anamespacesigc_html_a0ae3b8a1ba26920cee4d7d9df2c39ed9"><div class="ttname"><a href="namespacesigc.html#a0ae3b8a1ba26920cee4d7d9df2c39ed9">sigc::exception_catch</a></div><div class="ttdeci">exception_catch_functor&lt; T_functor, T_catcher &gt; exception_catch(const T_functor &amp;_A_func, const T_catcher &amp;_A_catcher)</div><div class="ttdef"><b>Definition:</b> exception_catch.h:326</div></div>
71 </div><!-- fragment --></dd></dl>
72 <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>
73 <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>
74 <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>
75 <div class="ttc" id="aclasssigc_1_1signal7_html_adc55ac9b0f935fd87a67904022e03cb2"><div class="ttname"><a href="classsigc_1_1signal7.html#adc55ac9b0f935fd87a67904022e03cb2">sigc::signal7::connect</a></div><div class="ttdeci">iterator connect(const slot_type &amp;slot_)</div><div class="ttdoc">Add a slot to the list of slots.</div><div class="ttdef"><b>Definition:</b> signal.h:3871</div></div>
76 <div class="ttc" id="aclasssigc_1_1signal_html"><div class="ttname"><a href="classsigc_1_1signal.html">sigc::signal</a></div><div class="ttdoc">Convenience wrapper for the numbered sigc::signal# templates.</div><div class="ttdef"><b>Definition:</b> signal.h:4015</div></div>
77 </div><!-- fragment --> </dd></dl>
78 </div><!-- contents -->
79 <!-- start footer part -->
80 <hr class="footer"/><address class="footer"><small>
81 Generated on Fri Feb 11 2022 15:40:57 for libsigc++ by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1
82 </small></address>
83 </body>
84 </html>