Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > ba6e5e1a033bd8535c43a771ce407926 > files > 408

lib64cxx-gtk-utils2.2-devel-2.2.3-2.mga4.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"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.4"/>
<title>c++-gtk-utils: mem_fun.h File Reference</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">c++-gtk-utils
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.4 -->
  <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>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_101f02d72531e1268e20029abbed11e1.html">c++-gtk-utils</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#namespaces">Namespaces</a> &#124;
<a href="#namespaces">Constant Groups</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">mem_fun.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>This file contains an adaptor to create a functor from a class member function to pass to C++ standard algorithms.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;functional&gt;</code><br/>
<code>#include &lt;<a class="el" href="cgu__config_8h_source.html">c++-gtk-utils/cgu_config.h</a>&gt;</code><br/>
</div>
<p><a href="mem__fun_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1MemFun_1_1Functor1.html">Cgu::MemFun::Functor1&lt; Ret, Arg, T &gt;</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1MemFun_1_1Functor1__const.html">Cgu::MemFun::Functor1_const&lt; Ret, Arg, T &gt;</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1MemFun_1_1Functor2.html">Cgu::MemFun::Functor2&lt; Ret, Arg1, Arg2, T &gt;</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCgu_1_1MemFun_1_1Functor2__const.html">Cgu::MemFun::Functor2_const&lt; Ret, Arg1, Arg2, T &gt;</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="namespaces"></a>
Namespaces</h2></td></tr>
<tr class="memitem:namespaceCgu_1_1MemFun"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespaceCgu_1_1MemFun.html">Cgu::MemFun</a></td></tr>
<tr class="memdesc:namespaceCgu_1_1MemFun"><td class="mdescLeft">&#160;</td><td class="mdescRight">This namespace contains an adaptor to create a functor from a class member function to pass to C++ standard algorithms. <br/></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:namespaceCgu"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespaceCgu.html">Cgu</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="namespaces"></a>
Constant Groups</h2></td></tr>
<tr class="memitem:namespaceCgu_1_1MemFun"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespaceCgu_1_1MemFun.html">Cgu::MemFun</a></td></tr>
<tr class="memdesc:namespaceCgu_1_1MemFun"><td class="mdescLeft">&#160;</td><td class="mdescRight">This namespace contains an adaptor to create a functor from a class member function to pass to C++ standard algorithms. <br/></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:namespaceCgu"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespaceCgu.html">Cgu</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a0b7e21248df91c69935baffed494998e"><td class="memTemplParams" colspan="2">template&lt;class Ret , class Arg , class T &gt; </td></tr>
<tr class="memitem:a0b7e21248df91c69935baffed494998e"><td class="memTemplItemLeft" align="right" valign="top">Functor1&lt; Ret, Arg, T &gt;&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="namespaceCgu_1_1MemFun.html#a0b7e21248df91c69935baffed494998e">Cgu::MemFun::make</a> (T &amp;t, Ret(T::*func)(Arg))</td></tr>
<tr class="separator:a0b7e21248df91c69935baffed494998e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:acef82af991d978c1eabc9b026befd680"><td class="memTemplParams" colspan="2">template&lt;class Ret , class Arg , class T &gt; </td></tr>
<tr class="memitem:acef82af991d978c1eabc9b026befd680"><td class="memTemplItemLeft" align="right" valign="top">Functor1_const&lt; Ret, Arg, T &gt;&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="namespaceCgu_1_1MemFun.html#acef82af991d978c1eabc9b026befd680">Cgu::MemFun::make</a> (const T &amp;t, Ret(T::*func)(Arg) const)</td></tr>
<tr class="separator:acef82af991d978c1eabc9b026befd680"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aad5673c187851ca018ba6b84e4547ee3"><td class="memTemplParams" colspan="2">template&lt;class Ret , class Arg1 , class Arg2 , class T &gt; </td></tr>
<tr class="memitem:aad5673c187851ca018ba6b84e4547ee3"><td class="memTemplItemLeft" align="right" valign="top">Functor2&lt; Ret, Arg1, Arg2, T &gt;&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="namespaceCgu_1_1MemFun.html#aad5673c187851ca018ba6b84e4547ee3">Cgu::MemFun::make</a> (T &amp;t, Ret(T::*func)(Arg1, Arg2))</td></tr>
<tr class="separator:aad5673c187851ca018ba6b84e4547ee3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5a085eca3ece796cf7b4d03be6865b5b"><td class="memTemplParams" colspan="2">template&lt;class Ret , class Arg1 , class Arg2 , class T &gt; </td></tr>
<tr class="memitem:a5a085eca3ece796cf7b4d03be6865b5b"><td class="memTemplItemLeft" align="right" valign="top">Functor2_const&lt; Ret, Arg1, <br class="typebreak"/>
Arg2, T &gt;&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="namespaceCgu_1_1MemFun.html#a5a085eca3ece796cf7b4d03be6865b5b">Cgu::MemFun::make</a> (const T &amp;t, Ret(T::*func)(Arg1, Arg2) const)</td></tr>
<tr class="separator:a5a085eca3ece796cf7b4d03be6865b5b"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>This file contains an adaptor to create a functor from a class member function to pass to C++ standard algorithms. </p>
<p>#include &lt;c++-gtk-utils/mem_fun.h&gt;</p>
<p><a class="el" href="namespaceCgu_1_1MemFun.html#a0b7e21248df91c69935baffed494998e">Cgu::MemFun::make()</a> is provided in order to provide source compatibility with the 1.2 series of the library. In C++11 it is superseded by std::mem_fn() and std::bind.</p>
<p><a class="el" href="namespaceCgu_1_1MemFun.html#a0b7e21248df91c69935baffed494998e">Cgu::MemFun::make()</a> is an adaptor which allows a non-static class member function to be called by standard algorithms such as std::for_each() or std::transform(), whereby the member function is passed a contained object as an argument on iterating through the container. It can also be used to make predicates from member functions to pass to other algorithms, or indeed to generate a general functor object representing a member function with object and one or two arguments. It does the equivalent of std::ptr_fun() for ordinary functions.</p>
<p>For example, to iterate over a std::vector&lt;int&gt; container object named 'vec', calling a class method 'void MyObj::my_method(int)' on each iteration, <a class="el" href="namespaceCgu_1_1MemFun.html#a0b7e21248df91c69935baffed494998e">Cgu::MemFun::make()</a> could be invoked as:</p>
<div class="fragment"><div class="line"><span class="keyword">using namespace </span>Cgu;</div>
<div class="line">std::for_each(vec.begin(), vec.end(),</div>
<div class="line">              <a class="code" href="namespaceCgu_1_1MemFun.html#a0b7e21248df91c69935baffed494998e">MemFun::make</a>(my_obj, &amp;MyObj::my_method));</div>
</div><!-- fragment --><p>As in the case of std::ptr_fun(), when called via std::for_each(), the member function called must be a unary function, although an additional argument can be bound with std::bind2nd() or std::bind1st() to enable it to be used with binary class functions. (Note that in many implementations of std::bind1st/2nd, neither the free nor the bound argument can be a reference, whether const or non-const. A reference argument can be employed with <a class="el" href="namespaceCgu_1_1MemFun.html#a0b7e21248df91c69935baffed494998e">Cgu::MemFun::make()</a> where std::bind1st/2nd is not used.) This limitation with respect to reference arguments is not present with std::mem_fn() and std::bind.</p>
<p>In C++11, the above example could be reproduced as:</p>
<div class="fragment"><div class="line"><span class="keyword">using namespace </span>std::placeholders;  <span class="comment">// for _1</span></div>
<div class="line">std::for_each(vec.begin(), vec.end(),</div>
<div class="line">              std::bind(&amp;MyObj::my_method, &amp;my_obj, _1));</div>
</div><!-- fragment --> </div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Mon Sep 16 2013 20:45:30 for c++-gtk-utils by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.4
</small></address>
</body>
</html>