<!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"/> <title>libsigc++: compose()</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" /> </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++  <span id="projectnumber">2.2.11</span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.1.1 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main 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><!-- top --> <div class="header"> <div class="summary"> <a href="#nested-classes">Classes</a> | <a href="#func-members">Functions</a> </div> <div class="headertitle"> <div class="title">compose()</div> </div> <div class="ingroups"><a class="el" href="group__adaptors.html">Adaptors</a></div></div><!--header--> <div class="contents"> <p><a class="el" href="group__compose.html#ga34cf5da8f6323bfdc41bc7113d6ad20a" title="Creates an adaptor of type sigc::compose1_functor which combines two functors.">sigc::compose()</a> combines two or three arbitrary functors. <a href="#details">More...</a></p> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2><a name="nested-classes"></a> Classes</h2></td></tr> <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="structsigc_1_1compose1__functor.html">sigc::compose1_functor< T_setter, T_getter ></a></td></tr> <tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight">Adaptor that combines two functors. <a href="structsigc_1_1compose1__functor.html#details">More...</a><br/></td></tr> <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="structsigc_1_1compose2__functor.html">sigc::compose2_functor< T_setter, T_getter1, T_getter2 ></a></td></tr> <tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight">Adaptor that combines three functors. <a href="structsigc_1_1compose2__functor.html#details">More...</a><br/></td></tr> </table><table class="memberdecls"> <tr class="heading"><td colspan="2"><h2><a name="func-members"></a> Functions</h2></td></tr> <tr class="memitem:gab7db81a28c43ca8fecc448c9c6f7a17d"><td class="memTemplParams" colspan="2">template<class T_action , class T_setter , class T_getter > </td></tr> <tr class="memitem:gab7db81a28c43ca8fecc448c9c6f7a17d"><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__compose.html#gab7db81a28c43ca8fecc448c9c6f7a17d">sigc::visit_each</a> (const T_action& _A_action, const compose1_functor< T_setter, T_getter >& _A_target)</td></tr> <tr class="memdesc:gab7db81a28c43ca8fecc448c9c6f7a17d"><td class="mdescLeft"> </td><td class="mdescRight">Performs a functor on each of the targets of a functor. <a href="#gab7db81a28c43ca8fecc448c9c6f7a17d"></a><br/></td></tr> <tr class="memitem:ga9aca4eabaf81b92b2cbb5c7a4ebfbb33"><td class="memTemplParams" colspan="2">template<class T_action , class T_setter , class T_getter1 , class T_getter2 > </td></tr> <tr class="memitem:ga9aca4eabaf81b92b2cbb5c7a4ebfbb33"><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__compose.html#ga9aca4eabaf81b92b2cbb5c7a4ebfbb33">sigc::visit_each</a> (const T_action& _A_action, const compose2_functor< T_setter, T_getter1, T_getter2 >& _A_target)</td></tr> <tr class="memdesc:ga9aca4eabaf81b92b2cbb5c7a4ebfbb33"><td class="mdescLeft"> </td><td class="mdescRight">Performs a functor on each of the targets of a functor. <a href="#ga9aca4eabaf81b92b2cbb5c7a4ebfbb33"></a><br/></td></tr> <tr class="memitem:ga34cf5da8f6323bfdc41bc7113d6ad20a"><td class="memTemplParams" colspan="2">template<class T_setter , class T_getter > </td></tr> <tr class="memitem:ga34cf5da8f6323bfdc41bc7113d6ad20a"><td class="memTemplItemLeft" align="right" valign="top">compose1_functor< T_setter, <br class="typebreak"/> T_getter > </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__compose.html#ga34cf5da8f6323bfdc41bc7113d6ad20a">sigc::compose</a> (const T_setter& _A_setter, const T_getter& _A_getter)</td></tr> <tr class="memdesc:ga34cf5da8f6323bfdc41bc7113d6ad20a"><td class="mdescLeft"> </td><td class="mdescRight">Creates an adaptor of type <a class="el" href="structsigc_1_1compose1__functor.html" title="Adaptor that combines two functors.">sigc::compose1_functor</a> which combines two functors. <a href="#ga34cf5da8f6323bfdc41bc7113d6ad20a"></a><br/></td></tr> <tr class="memitem:ga4abf2a45eb2307a3dc5d870c86b0450d"><td class="memTemplParams" colspan="2">template<class T_setter , class T_getter1 , class T_getter2 > </td></tr> <tr class="memitem:ga4abf2a45eb2307a3dc5d870c86b0450d"><td class="memTemplItemLeft" align="right" valign="top">compose2_functor< T_setter, <br class="typebreak"/> T_getter1, T_getter2 > </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__compose.html#ga4abf2a45eb2307a3dc5d870c86b0450d">sigc::compose</a> (const T_setter& _A_setter, const T_getter1& _A_getter1, const T_getter2& _A_getter2)</td></tr> <tr class="memdesc:ga4abf2a45eb2307a3dc5d870c86b0450d"><td class="mdescLeft"> </td><td class="mdescRight">Creates an adaptor of type <a class="el" href="structsigc_1_1compose2__functor.html" title="Adaptor that combines three functors.">sigc::compose2_functor</a> which combines three functors. <a href="#ga4abf2a45eb2307a3dc5d870c86b0450d"></a><br/></td></tr> </table> <hr/><a name="details" id="details"></a><h2>Detailed Description</h2> <p><a class="el" href="group__compose.html#ga34cf5da8f6323bfdc41bc7113d6ad20a" title="Creates an adaptor of type sigc::compose1_functor which combines two functors.">sigc::compose()</a> combines two or three arbitrary functors. </p> <p>On invokation, parameters are passed on to one or two getter functor(s). The return value(s) are then passed on to the setter function.</p> <dl class="section user"><dt>Examples:</dt><dd><div class="fragment"><div class="line"> <span class="keywordtype">float</span> square_root(<span class="keywordtype">float</span> a) { <span class="keywordflow">return</span> sqrtf(a); }</div> <div class="line"> <span class="keywordtype">float</span> <a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01661.html#ga00295ac42c201866e7178edb6878b316">sum</a>(<span class="keywordtype">float</span> a, <span class="keywordtype">float</span> b) { <span class="keywordflow">return</span> a+b; }</div> <div class="line"> <a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01622.html#aaf93fdf0812752e0e02c501dea1b38f0">std::cout</a> << <a class="code" href="group__compose.html#ga34cf5da8f6323bfdc41bc7113d6ad20a" title="Creates an adaptor of type sigc::compose1_functor which combines two functors.">sigc::compose</a>(&square_root, &<a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01661.html#ga00295ac42c201866e7178edb6878b316">sum</a>)(9, 16); <span class="comment">// calls square_root(sum(3,6))</span></div> <div class="line"> <a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01622.html#aaf93fdf0812752e0e02c501dea1b38f0">std::cout</a> << <a class="code" href="group__compose.html#ga34cf5da8f6323bfdc41bc7113d6ad20a" title="Creates an adaptor of type sigc::compose1_functor which combines two functors.">sigc::compose</a>(&<a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01661.html#ga00295ac42c201866e7178edb6878b316">sum</a>, &square_root, &square_root)(9); <span class="comment">// calls sum(square_root(9), square_root(9))</span></div> </div><!-- fragment --></dd></dl> <p>The functor <a class="el" href="group__compose.html#ga34cf5da8f6323bfdc41bc7113d6ad20a" title="Creates an adaptor of type sigc::compose1_functor which combines two functors.">sigc::compose()</a> returns can be passed directly 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" title="Convenience wrapper for the numbered sigc::signal# templates.">sigc::signal<float,float,float></a> some_signal;</div> <div class="line"> some_signal.<a class="code" href="classsigc_1_1signal7.html#adc55ac9b0f935fd87a67904022e03cb2" title="Add a slot to the list of slots.">connect</a>(<a class="code" href="group__compose.html#ga34cf5da8f6323bfdc41bc7113d6ad20a" title="Creates an adaptor of type sigc::compose1_functor which combines two functors.">sigc::compose</a>(&square_root, &<a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01661.html#ga00295ac42c201866e7178edb6878b316">sum</a>));</div> </div><!-- fragment --></dd></dl> <p>For a more powerful version of this functionality see the lambda library adaptor sigc::group() which can bind, hide and reorder arguments arbitrarily. Although sigc::group() is more flexible, <a class="el" href="group__bind.html#ga2f099bc6056b32f2a58134ba8537c6f4" title="Creates an adaptor of type sigc::bind_functor which binds the passed argument to the passed functor...">sigc::bind()</a> provides a means of binding parameters when the total number of parameters called is variable. </p> <hr/><h2>Function Documentation</h2> <a class="anchor" id="ga34cf5da8f6323bfdc41bc7113d6ad20a"></a> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template <class T_setter , class T_getter > </div> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">compose1_functor<T_setter, T_getter> sigc::compose </td> <td>(</td> <td class="paramtype">const T_setter & </td> <td class="paramname"><em>_A_setter</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const T_getter & </td> <td class="paramname"><em>_A_getter</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">inline</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>Creates an adaptor of type <a class="el" href="structsigc_1_1compose1__functor.html" title="Adaptor that combines two functors.">sigc::compose1_functor</a> which combines two functors. </p> <dl class="params"><dt>Parameters:</dt><dd> <table class="params"> <tr><td class="paramname">_A_setter</td><td>Functor that receives the return value of the invokation of <em>_A_getter</em>. </td></tr> <tr><td class="paramname">_A_getter</td><td>Functor to invoke from operator()(). </td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns:</dt><dd>Adaptor that executes <em>_A_setter</em> with the value returned from invokation of <em>_A_getter</em>. </dd></dl> </div> </div> <a class="anchor" id="ga4abf2a45eb2307a3dc5d870c86b0450d"></a> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template <class T_setter , class T_getter1 , class T_getter2 > </div> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname">compose2_functor<T_setter, T_getter1, T_getter2> sigc::compose </td> <td>(</td> <td class="paramtype">const T_setter & </td> <td class="paramname"><em>_A_setter</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const T_getter1 & </td> <td class="paramname"><em>_A_getter1</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const T_getter2 & </td> <td class="paramname"><em>_A_getter2</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">inline</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>Creates an adaptor of type <a class="el" href="structsigc_1_1compose2__functor.html" title="Adaptor that combines three functors.">sigc::compose2_functor</a> which combines three functors. </p> <dl class="params"><dt>Parameters:</dt><dd> <table class="params"> <tr><td class="paramname">_A_setter</td><td>Functor that receives the return values of the invokation of <em>_A_getter1</em> and <em>_A_getter2</em>. </td></tr> <tr><td class="paramname">_A_getter1</td><td>Functor to invoke from operator()(). </td></tr> <tr><td class="paramname">_A_getter2</td><td>Functor to invoke from operator()(). </td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns:</dt><dd>Adaptor that executes <em>_A_setter</em> with the values return from invokation of <em>_A_getter1</em> and <em>_A_getter2</em>. </dd></dl> </div> </div> <a class="anchor" id="gab7db81a28c43ca8fecc448c9c6f7a17d"></a> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template <class T_action , class T_setter , class T_getter > </div> <table class="memname"> <tr> <td class="memname">void sigc::visit_each </td> <td>(</td> <td class="paramtype">const T_action & </td> <td class="paramname"><em>_A_action</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const compose1_functor< T_setter, T_getter > & </td> <td class="paramname"><em>_A_target</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Performs a functor on each of the targets of a functor. </p> <p>The function overload for <a class="el" href="structsigc_1_1compose1__functor.html" title="Adaptor that combines two functors.">sigc::compose1_functor</a> performs a functor on the functors stored in the <a class="el" href="structsigc_1_1compose1__functor.html" title="Adaptor that combines two functors.">sigc::compose1_functor</a> object. </p> </div> </div> <a class="anchor" id="ga9aca4eabaf81b92b2cbb5c7a4ebfbb33"></a> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template <class T_action , class T_setter , class T_getter1 , class T_getter2 > </div> <table class="memname"> <tr> <td class="memname">void sigc::visit_each </td> <td>(</td> <td class="paramtype">const T_action & </td> <td class="paramname"><em>_A_action</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const compose2_functor< T_setter, T_getter1, T_getter2 > & </td> <td class="paramname"><em>_A_target</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Performs a functor on each of the targets of a functor. </p> <p>The function overload for <a class="el" href="structsigc_1_1compose2__functor.html" title="Adaptor that combines three functors.">sigc::compose2_functor</a> performs a functor on the functors stored in the <a class="el" href="structsigc_1_1compose2__functor.html" title="Adaptor that combines three functors.">sigc::compose2_functor</a> object. </p> </div> </div> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.1.1 </small></address> </body> </html>