Sophie

Sophie

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

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++: group()</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>group()<br/>
<small>
[<a class="el" href="group__adaptors.html">Adaptors</a>,&#160;<a class="el" href="group__lambdas.html">Lambdas</a>]</small>
</h1>
<p>sigc::group() alters an arbitrary functor by rebuilding its arguments from one or more lambda expressions. <a href="#_details">More...</a></p>
<table border="0" cellpadding="0" cellspacing="0">
</table>
<p>sigc::group() alters an arbitrary functor by rebuilding its arguments from one or more lambda expressions. </p>
<p>For each parameter that should be passed to the wrapped functor one lambda expression has to be passed into group(). Lambda selectors can be used as placeholders for the arguments passed into the new functor. Arguments that don't have a placeholder in one of the lambda expressions are dropped.</p>
<dl class="user"><dt><b>Examples:</b></dt><dd><div class="fragment"><pre class="fragment"> <span class="keywordtype">void</span> foo(<span class="keywordtype">int</span>, <span class="keywordtype">int</span>);
   <span class="keywordtype">int</span> bar(<span class="keywordtype">int</span>);
   <span class="comment">// argument binding ...</span>
   sigc::group(&amp;foo,10,sigc::_1)(20); <span class="comment">//fixes the first argument and calls foo(10,20)</span>
   sigc::group(&amp;foo,sigc::_1,30)(40); <span class="comment">//fixes the second argument and calls foo(40,30)</span>
   <span class="comment">// argument reordering ...</span>
   sigc::group(&amp;foo,sigc::_2,sigc::_1)(1,2); <span class="comment">//calls foo(2,1)</span>
   <span class="comment">// argument hiding ...</span>
   sigc::group(&amp;foo,sigc::_1,sigc::_2)(1,2,3); <span class="comment">//calls foo(1,2)</span>
   <span class="comment">// functor composition ...</span>
   sigc::group(&amp;foo,sigc::_1,sigc::group(&amp;bar,sigc::_2))(1,2); <span class="comment">//calls foo(1,bar(2))</span>
   <span class="comment">// algebraic expressions ...</span>
   sigc::group(&amp;foo,sigc::_1*sigc::_2,sigc::_1/sigc::_2)(6,3); <span class="comment">//calls foo(6*3,6/3)</span>
</pre></div></dd></dl>
<p>The functor sigc::group() 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;void,int,int&gt;</a> some_signal;
   <span class="keywordtype">void</span> foo(<span class="keywordtype">int</span>);
   some_signal.<a class="code" href="classsigc_1_1signal7.html#adc55ac9b0f935fd87a67904022e03cb2" title="Add a slot to the list of slots.">connect</a>(sigc::group(&amp;foo,sigc::_2));
</pre></div></dd></dl>
<p>Like in <a class="el" href="group__bind.html#ga2148290d2cf9c1961ec157a085badd5a" title="Creates an adaptor of type sigc::bind_functor which binds the passed argument to...">sigc::bind()</a> you can bind references to functors by passing the objects through the <a class="el" href="namespacesigc.html#ad6e63f1697c807728f518f21f69e1931" title="Creates a reference wrapper.">sigc::ref()</a> helper function.</p>
<dl class="user"><dt><b>Example:</b></dt><dd><div class="fragment"><pre class="fragment"> <span class="keywordtype">int</span> some_int;
   <a class="code" href="classsigc_1_1signal.html" title="Convenience wrapper for the numbered sigc::signal# templates.">sigc::signal&lt;void&gt;</a> some_signal;
   <span class="keywordtype">void</span> foo(<span class="keywordtype">int</span>&amp;);
   some_signal.<a class="code" href="classsigc_1_1signal7.html#adc55ac9b0f935fd87a67904022e03cb2" title="Add a slot to the list of slots.">connect</a>(sigc::group(&amp;foo,<a class="code" href="namespacesigc.html#ad6e63f1697c807728f518f21f69e1931" title="Creates a reference wrapper.">sigc::ref</a>(some_int)));
</pre></div></dd></dl>
<p>If you bind an object of a <a class="el" href="structsigc_1_1trackable.html" title="Base class for objects with auto-disconnection.">sigc::trackable</a> derived type to a functor by reference, a slot assigned to the group adaptor is cleared automatically when the object goes out of scope.</p>
<dl class="user"><dt><b>Example:</b></dt><dd><div class="fragment"><pre class="fragment"> <span class="keyword">struct </span>bar : <span class="keyword">public</span> sigc::trackable {} some_bar;
   <a class="code" href="classsigc_1_1signal.html" title="Convenience wrapper for the numbered sigc::signal# templates.">sigc::signal&lt;void&gt;</a> some_signal;
   <span class="keywordtype">void</span> foo(bar&amp;);
   some_signal.<a class="code" href="classsigc_1_1signal7.html#adc55ac9b0f935fd87a67904022e03cb2" title="Add a slot to the list of slots.">connect</a>(sigc::group(&amp;foo,<a class="code" href="namespacesigc.html#ad6e63f1697c807728f518f21f69e1931" title="Creates a reference wrapper.">sigc::ref</a>(some_bar)));
     <span class="comment">// disconnected automatically if some_bar goes out of scope</span>
</pre></div></dd></dl>
<p>, </p>
</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>