Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > c74ab286c3d46f9b82671d206e43a74b > files > 1681

libstdc++-docs-4.6.3-2.fc15.i686.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>libstdc++: Function Objects</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.4 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">libstdc++</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a01193.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#groups">Modules</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Function Objects</div>  </div>
<div class="ingroups"><a class="el" href="a01176.html">Utilities</a></div></div>
<div class="contents">
<div class="dynheader">
Collaboration diagram for Function Objects:</div>
<div class="dyncontent">
<center><table><tr><td><img src="a01193.png" border="0" alt="" usemap="#a01193"/>
<map name="a01193" id="a01193">
<area shape="rect" id="node1" href="a01176.html" title="Utilities" alt="" coords="7,192,68,221"/><area shape="rect" id="node2" href="a01189.html" title="Hashes" alt="" coords="349,5,413,35"/><area shape="rect" id="node3" href="a01196.html" title="Boolean Operations Classes" alt="" coords="292,59,471,88"/><area shape="rect" id="node4" href="a01199.html" title="Adaptors for pointers to members" alt="" coords="280,112,483,141"/><area shape="rect" id="node5" href="a01198.html" title="Adaptors for pointers to functions" alt="" coords="281,165,481,195"/><area shape="rect" id="node6" href="a01180.html" title="Binder Classes" alt="" coords="329,219,433,248"/><area shape="rect" id="node7" href="a01195.html" title="Comparison Classes" alt="" coords="313,272,449,301"/><area shape="rect" id="node8" href="a01197.html" title="Negators" alt="" coords="345,325,417,355"/><area shape="rect" id="node10" href="a01194.html" title="Arithmetic Classes" alt="" coords="320,379,443,408"/></map>
</td></tr></table></center>
</div>
<h2><a name="nested-classes"></a>
Classes</h2>
<ul>
<li>struct <a class="el" href="a00254.html">std::binary_function&lt; _Arg1, _Arg2, _Result &gt;</a>
<li>class <a class="el" href="a00478.html">std::function&lt; _Res(_ArgTypes...)&gt;</a>
<dl class="el"><dd class="mdescRight">Primary class template for std::function.Polymorphic function wrapper.  <a href="a00478.html#details">More...</a><br/></dl><li>class <a class="el" href="a00681.html">std::reference_wrapper&lt; _Tp &gt;</a>
<dl class="el"><dd class="mdescRight">Primary class template for <a class="el" href="a00681.html" title="Primary class template for reference_wrapper.">reference_wrapper</a>.  <a href="a00681.html#details">More...</a><br/></dl><li>struct <a class="el" href="a00723.html">std::unary_function&lt; _Arg, _Result &gt;</a>
</ul>
<h2><a name="groups"></a>
Modules</h2>
<ul>
<li><a class="el" href="a01180.html">Binder Classes</a>
<li><a class="el" href="a01189.html">Hashes</a>
<li><a class="el" href="a01194.html">Arithmetic Classes</a>
<li><a class="el" href="a01195.html">Comparison Classes</a>
<li><a class="el" href="a01196.html">Boolean Operations Classes</a>
<li><a class="el" href="a01197.html">Negators</a>
<li><a class="el" href="a01198.html">Adaptors for pointers to functions</a>
<li><a class="el" href="a01199.html">Adaptors for pointers to members</a>
</ul>
<h2><a name="func-members"></a>
Functions</h2>
<ul>
<li>template&lt;typename _Tp , typename _Class &gt; _Mem_fn&lt; _Tp _Class::* &gt; <a class="el" href="a01193.html#ga69eb0d461f9c7b7395281721315882d2">std::mem_fn</a> (_Tp _Class::*__pm)
</ul>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<p>Function objects, or <em>functors</em>, are objects with an <code>operator()</code> defined and accessible. They can be passed as arguments to algorithm templates and used in place of a function pointer. Not only is the resulting expressiveness of the library increased, but the generated code can be more efficient than what you might write by hand. When we refer to <em>functors</em>, then, generally we include function pointers in the description as well.</p>
<p>Often, functors are only created as temporaries passed to algorithm calls, rather than being created as named variables.</p>
<p>Two examples taken from the standard itself follow. To perform a by-element addition of two vectors <code>a</code> and <code>b</code> containing <code>double</code>, and put the result in <code>a</code>, use </p>
<div class="fragment"><pre class="fragment">  transform (a.begin(), a.end(), b.begin(), a.begin(), plus&lt;double&gt;());
</pre></div><p> To negate every element in <code>a</code>, use </p>
<div class="fragment"><pre class="fragment">  transform(a.begin(), a.end(), a.begin(), negate&lt;double&gt;());
</pre></div><p> The addition and negation functions will be inlined directly.</p>
<p>The standard functors are derived from structs named <code><a class="el" href="a00723.html">unary_function</a></code> and <code><a class="el" href="a00254.html">binary_function</a></code>. These two classes contain nothing but typedefs, to aid in generic (template) programming. If you write your own functors, you might consider doing the same. </p>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="ga69eb0d461f9c7b7395281721315882d2"></a><!-- doxytag: member="std::mem_fn" ref="ga69eb0d461f9c7b7395281721315882d2" args="(_Tp _Class::*__pm)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename _Tp , typename _Class &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">_Mem_fn&lt;_Tp _Class::*&gt; std::mem_fn </td>
          <td>(</td>
          <td class="paramtype">_Tp _Class::*&#160;</td>
          <td class="paramname"><em>__pm</em></td><td>)</td>
          <td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Returns a function object that forwards to the member pointer <em>pm</em>. </p>

<p>Definition at line <a class="el" href="a00884_source.html#l00818">818</a> of file <a class="el" href="a00884_source.html">functional</a>.</p>

</div>
</div>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="footer">Generated by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </li>
    </ul>
  </div>

</body>
</html>