3 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4 <title>Retyping</title>
5 <meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
6 <link rel="home" href="index.html" title="libsigc++">
7 <link rel="up" href="chapter-advanced.html" title="Chapter 4. Advanced topics">
8 <link rel="prev" href="chapter-advanced.html" title="Chapter 4. Advanced topics">
9 <link rel="next" href="chapter-reference.html" title="Chapter 5. Reference">
11 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
12 <div class="navheader">
13 <table width="100%" summary="Navigation header">
14 <tr><th colspan="3" align="center">Retyping</th></tr>
16 <td width="20%" align="left">
17 <a accesskey="p" href="chapter-advanced.html">Prev</a> </td>
18 <th width="60%" align="center">Chapter 4. Advanced topics</th>
19 <td width="20%" align="right"> <a accesskey="n" href="chapter-reference.html">Next</a>
26 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
27 <a name="sect-retyping"></a>Retyping</h2></div></div></div>
30 <p>A similar topic is retyping. Perhaps you have a signal that takes an <code class="literal">int</code>, but
31 you want to connect a function that takes a <code class="literal">double</code>.</p>
33 <p>This can be achieved with the <code class="literal">sigc::retype()</code> template.
34 It takes a <code class="literal">sigc::slot</code>, and returns a <code class="literal">sigc::slot</code>. eg.</p>
36 <pre class="programlisting">
37 void dostuff(double foo)
41 sigc::signal<void(int)> asignal;
43 asignal.connect( sigc::retype( sigc::ptr_fun(&dostuff) ) );
46 <p>If you only want to change the return type, you can use <code class="literal">sigc::retype_return()</code>.
47 <code class="literal">retype_return()</code> needs one template argument, the new return type.</p>
49 <div class="navfooter">
51 <table width="100%" summary="Navigation footer">
53 <td width="40%" align="left">
54 <a accesskey="p" href="chapter-advanced.html">Prev</a> </td>
55 <td width="20%" align="center"><a accesskey="u" href="chapter-advanced.html">Up</a></td>
56 <td width="40%" align="right"> <a accesskey="n" href="chapter-reference.html">Next</a>
60 <td width="40%" align="left" valign="top">Chapter 4. Advanced topics </td>
61 <td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
62 <td width="40%" align="right" valign="top"> Chapter 5. Reference</td>