<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://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.15"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <title>libstdc++: Adaptors for pointers to functions</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="navtree.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript" src="navtreedata.js"></script> <script type="text/javascript" src="navtree.js"></script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ $(document).ready(initResizable); /* @license-end */</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 id="projectalign" style="padding-left: 0.5em;"> <div id="projectname">libstdc++ </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.15 --> </div><!-- top --> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> <div id="nav-sync" class="sync"></div> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ $(document).ready(function(){initNavTree('a01501.html','');}); /* @license-end */ </script> <div id="doc-content"> <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">Adaptors for pointers to functions<div class="ingroups"><a class="el" href="a01477.html">Utilities</a> » <a class="el" href="a01496.html">Function Objects</a></div></div> </div> </div><!--header--> <div class="contents"> <div class="dynheader"> Collaboration diagram for Adaptors for pointers to functions:</div> <div class="dyncontent"> <center><table><tr><td><div class="center"><iframe scrolling="no" frameborder="0" src="a01501.svg" width="307" height="48"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe> </div> </td></tr></table></center> </div> <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  </td><td class="memItemRight" valign="bottom"><a class="el" href="a07560.html">std::pointer_to_binary_function< _Arg1, _Arg2, _Result ></a></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class  </td><td class="memItemRight" valign="bottom"><a class="el" href="a07556.html">std::pointer_to_unary_function< _Arg, _Result ></a></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2"> </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:gaee61fcee12458d9d61b10f07de908134"><td class="memTemplParams" colspan="2">template<typename _Arg , typename _Result > </td></tr> <tr class="memitem:gaee61fcee12458d9d61b10f07de908134"><td class="memTemplItemLeft" align="right" valign="top"><a class="el" href="a07556.html">pointer_to_unary_function</a>< _Arg, _Result > </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a01501.html#gaee61fcee12458d9d61b10f07de908134">std::ptr_fun</a> (_Result(*__x)(_Arg))</td></tr> <tr class="separator:gaee61fcee12458d9d61b10f07de908134"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ga2c95cd7ca955ae3a4cbf98593456bd8e"><td class="memTemplParams" colspan="2">template<typename _Arg1 , typename _Arg2 , typename _Result > </td></tr> <tr class="memitem:ga2c95cd7ca955ae3a4cbf98593456bd8e"><td class="memTemplItemLeft" align="right" valign="top"><a class="el" href="a07560.html">pointer_to_binary_function</a>< _Arg1, _Arg2, _Result > </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a01501.html#ga2c95cd7ca955ae3a4cbf98593456bd8e">std::ptr_fun</a> (_Result(*__x)(_Arg1, _Arg2))</td></tr> <tr class="separator:ga2c95cd7ca955ae3a4cbf98593456bd8e"><td class="memSeparator" colspan="2"> </td></tr> </table> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <p>The advantage of function objects over pointers to functions is that the objects in the standard library declare nested typedefs describing their argument and result types with uniform names (e.g., <code>result_type</code> from the base classes <code>unary_function</code> and <code>binary_function</code>). Sometimes those typedefs are required, not just optional.</p> <p>Adaptors are provided to turn pointers to unary (single-argument) and binary (double-argument) functions into function objects. The long-winded functor <code>pointer_to_unary_function</code> is constructed with a function pointer <code>f</code>, and its <code>operator()</code> called with argument <code>x</code> returns <code>f(x)</code>. The functor <code>pointer_to_binary_function</code> does the same thing, but with a double-argument <code>f</code> and <code>operator()</code>.</p> <p>The function <code>ptr_fun</code> takes a pointer-to-function <code>f</code> and constructs an instance of the appropriate functor. </p> <h2 class="groupheader">Function Documentation</h2> <a id="gaee61fcee12458d9d61b10f07de908134"></a> <h2 class="memtitle"><span class="permalink"><a href="#gaee61fcee12458d9d61b10f07de908134">◆ </a></span>ptr_fun() <span class="overload">[1/2]</span></h2> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename _Arg , typename _Result > </div> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname"><a class="el" href="a07556.html">pointer_to_unary_function</a><_Arg, _Result> std::ptr_fun </td> <td>(</td> <td class="paramtype">_Result(*)(_Arg) </td> <td class="paramname"><em>__x</em></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>One of the <a class="el" href="a01501.html">adaptors for function pointers</a>. </p> <p class="definition">Definition at line <a class="el" href="a00542_source.html#l01076">1076</a> of file <a class="el" href="a00542_source.html">stl_function.h</a>.</p> </div> </div> <a id="ga2c95cd7ca955ae3a4cbf98593456bd8e"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga2c95cd7ca955ae3a4cbf98593456bd8e">◆ </a></span>ptr_fun() <span class="overload">[2/2]</span></h2> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename _Arg1 , typename _Arg2 , typename _Result > </div> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname"><a class="el" href="a07560.html">pointer_to_binary_function</a><_Arg1, _Arg2, _Result> std::ptr_fun </td> <td>(</td> <td class="paramtype">_Result(*)(_Arg1, _Arg2) </td> <td class="paramname"><em>__x</em></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>One of the <a class="el" href="a01501.html">adaptors for function pointers</a>. </p> <p class="definition">Definition at line <a class="el" href="a00542_source.html#l01102">1102</a> of file <a class="el" href="a00542_source.html">stl_function.h</a>.</p> </div> </div> </div><!-- contents --> </div><!-- doc-content --> <!-- start footer part --> <div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> <ul> <li class="footer">Generated by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.15 </li> </ul> </div> </body> </html>