1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Chapter 1. Boost.Member Function</title> 5<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="mem_fn.html" title="Chapter 1. Boost.Member Function"> 8</head> 9<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 10<table cellpadding="2" width="100%"><tr> 11<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td> 12<td align="center"><a href="../../../../index.html">Home</a></td> 13<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td> 14<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 15<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 16<td align="center"><a href="../../../../more/index.htm">More</a></td> 17</tr></table> 18<hr> 19<div class="spirit-nav"></div> 20<div class="chapter"> 21<div class="titlepage"><div> 22<div><h2 class="title"> 23<a name="mem_fn"></a>Chapter 1. Boost.Member Function</h2></div> 24<div><p class="copyright">Copyright © 2001, 2002 Peter Dimov and Multi Media Ltd.</p></div> 25<div><p class="copyright">Copyright © 2003-2005 Peter Dimov</p></div> 26<div><div class="legalnotice"> 27<a name="mem_fn.legal"></a><p> 28 Distributed under the <a href="http://boost.org/LICENSE_1_0.txt" target="_top">Boost 29 Software License, Version 1.0</a>. 30 </p> 31</div></div> 32</div></div> 33<div class="toc"> 34<p><b>Table of Contents</b></p> 35<dl class="toc"> 36<dt><span class="section"><a href="mem_fn.html#mem_fn.purpose">Purpose</a></span></dt> 37<dt><span class="section"><a href="mem_fn.html#mem_fn.faq">Frequently Asked Questions</a></span></dt> 38<dd><dl> 39<dt><span class="section"><a href="mem_fn.html#mem_fn.faq.can_mem_fn_be_used_instead_of_th">Can <code class="computeroutput"><span class="identifier">mem_fn</span></code> be used instead of the standard <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">mem_fun</span><span class="special">[</span><span class="identifier">_ref</span><span class="special">]</span></code> 40 adaptors?</a></span></dt> 41<dt><span class="section"><a href="mem_fn.html#mem_fn.faq.should_i_replace_every_occurence">Should I 42 replace every occurence of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">mem_fun</span><span class="special">[</span><span class="identifier">_ref</span><span class="special">]</span></code> 43 with <code class="computeroutput"><span class="identifier">mem_fn</span></code> in my existing 44 code?</a></span></dt> 45<dt><span class="section"><a href="mem_fn.html#mem_fn.faq.does_mem_fn_work_with_com_method">Does <code class="computeroutput"><span class="identifier">mem_fn</span></code> work with COM methods?</a></span></dt> 46<dt><span class="section"><a href="mem_fn.html#mem_fn.faq.why_isn_t_boost_mem_fn_enable_st">Why isn't 47 <code class="computeroutput"><span class="identifier">BOOST_MEM_FN_ENABLE_STDCALL</span></code> 48 defined automatically?</a></span></dt> 49</dl></dd> 50<dt><span class="section"><a href="mem_fn.html#mem_fn.interface">Interface</a></span></dt> 51<dd><dl> 52<dt><span class="section"><a href="mem_fn.html#mem_fn.interface.synopsys">Synopsis</a></span></dt> 53<dt><span class="section"><a href="mem_fn.html#mem_fn.interface.common_requirements">Common requirements</a></span></dt> 54<dt><span class="section"><a href="mem_fn.html#mem_fn.interface.get_pointer"><code class="computeroutput"><span class="identifier">get_pointer</span></code></a></span></dt> 55<dt><span class="section"><a href="mem_fn.html#mem_fn.interface.mem_fn"><code class="computeroutput"><span class="identifier">mem_fn</span></code></a></span></dt> 56</dl></dd> 57<dt><span class="section"><a href="mem_fn.html#mem_fn.implementation">Implementation</a></span></dt> 58<dd><dl> 59<dt><span class="section"><a href="mem_fn.html#mem_fn.implementation.files">Files</a></span></dt> 60<dt><span class="section"><a href="mem_fn.html#mem_fn.implementation.dependencies">Dependencies</a></span></dt> 61<dt><span class="section"><a href="mem_fn.html#mem_fn.implementation.number_of_arguments">Number of 62 Arguments</a></span></dt> 63<dt><span class="section"><a href="mem_fn.html#mem_fn.implementation.stdcall"><code class="computeroutput"><span class="identifier">__stdcall</span></code>, 64 <code class="computeroutput"><span class="identifier">__cdecl</span></code>, and <code class="computeroutput"><span class="identifier">__fastcall</span></code> Support</a></span></dt> 65</dl></dd> 66<dt><span class="section"><a href="mem_fn.html#mem_fn.acknowledgements">Acknowledgements</a></span></dt> 67</dl> 68</div> 69<div class="section"> 70<div class="titlepage"><div><div><h2 class="title" style="clear: both"> 71<a name="mem_fn.purpose"></a><a class="link" href="mem_fn.html#mem_fn.purpose" title="Purpose">Purpose</a> 72</h2></div></div></div> 73<p> 74 <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">mem_fn</span></code> is a generalization of the standard 75 functions <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">mem_fun</span></code> and <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">mem_fun_ref</span></code>. 76 It supports member function pointers with more than one argument, and the returned 77 function object can take a pointer, a reference, or a smart pointer to an object 78 instance as its first argument. <code class="computeroutput"><span class="identifier">mem_fn</span></code> 79 also supports pointers to data members by treating them as functions taking 80 no arguments and returning a (const) reference to the member. 81 </p> 82<p> 83 The purpose of <code class="computeroutput"><span class="identifier">mem_fn</span></code> is twofold. 84 First, it allows users to invoke a member function on a container with the 85 familiar 86 </p> 87<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">mem_fn</span><span class="special">(&</span><span class="identifier">Shape</span><span class="special">::</span><span class="identifier">draw</span><span class="special">));</span> 88</pre> 89<p> 90 syntax, even when the container stores smart pointers. 91 </p> 92<p> 93 Second, it can be used as a building block by library developers that want 94 to treat a pointer to member function as a function object. A library might 95 define an enhanced <code class="computeroutput"><span class="identifier">for_each</span></code> 96 algorithm with an overload of the form: 97 </p> 98<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">It</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">void</span> <span class="identifier">for_each</span><span class="special">(</span><span class="identifier">It</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">It</span> <span class="identifier">last</span><span class="special">,</span> <span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">())</span> 99<span class="special">{</span> 100 <span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">first</span><span class="special">,</span> <span class="identifier">last</span><span class="special">,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">mem_fn</span><span class="special">(</span><span class="identifier">pmf</span><span class="special">));</span> 101<span class="special">}</span> 102</pre> 103<p> 104 that will allow the convenient syntax: 105 </p> 106<pre class="programlisting"><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="special">&</span><span class="identifier">Shape</span><span class="special">::</span><span class="identifier">draw</span><span class="special">);</span> 107</pre> 108<p> 109 When documenting the feature, the library author will simply state: 110 </p> 111<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">It</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">void</span> <span class="identifier">for_each</span><span class="special">(</span><span class="identifier">It</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">It</span> <span class="identifier">last</span><span class="special">,</span> <span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">());</span> 112</pre> 113<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> 114 <span class="emphasis"><em>Effects:</em></span> Equivalent to <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">first</span><span class="special">,</span> <span class="identifier">last</span><span class="special">,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">mem_fn</span><span class="special">(</span><span class="identifier">pmf</span><span class="special">))</span></code>. 115 </li></ul></div> 116<p> 117 where <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">mem_fn</span></code> can be a link to this page. See the 118 <a href="../../../../libs/bind/bind.html" target="_top">documentation of <code class="computeroutput"><span class="identifier">bind</span></code></a> 119 for an example. 120 </p> 121<p> 122 <code class="computeroutput"><span class="identifier">mem_fn</span></code> takes one argument, 123 a pointer to a member, and returns a function object suitable for use with 124 standard or user-defined algorithms: 125 </p> 126<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">X</span> 127<span class="special">{</span> 128 <span class="keyword">void</span> <span class="identifier">f</span><span class="special">();</span> 129<span class="special">};</span> 130 131<span class="keyword">void</span> <span class="identifier">g</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">X</span><span class="special">></span> <span class="special">&</span> <span class="identifier">v</span><span class="special">)</span> 132<span class="special">{</span> 133 <span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">mem_fn</span><span class="special">(&</span><span class="identifier">X</span><span class="special">::</span><span class="identifier">f</span><span class="special">));</span> 134<span class="special">};</span> 135 136<span class="keyword">void</span> <span class="identifier">h</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">X</span> <span class="special">*></span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">v</span><span class="special">)</span> 137<span class="special">{</span> 138 <span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">mem_fn</span><span class="special">(&</span><span class="identifier">X</span><span class="special">::</span><span class="identifier">f</span><span class="special">));</span> 139<span class="special">};</span> 140 141<span class="keyword">void</span> <span class="identifier">k</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">shared_ptr</span><span class="special"><</span><span class="identifier">X</span><span class="special">></span> <span class="special">></span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">v</span><span class="special">)</span> 142<span class="special">{</span> 143 <span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">mem_fn</span><span class="special">(&</span><span class="identifier">X</span><span class="special">::</span><span class="identifier">f</span><span class="special">));</span> 144<span class="special">};</span> 145</pre> 146<p> 147 The returned function object takes the same arguments as the input member function 148 plus a "flexible" first argument that represents the object instance. 149 </p> 150<p> 151 When the function object is invoked with a first argument <code class="computeroutput"><span class="identifier">x</span></code> 152 that is neither a pointer nor a reference to the appropriate class (<code class="computeroutput"><span class="identifier">X</span></code> in the example above), it uses <code class="computeroutput"><span class="identifier">get_pointer</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code> to obtain 153 a pointer from <code class="computeroutput"><span class="identifier">x</span></code>. Library authors 154 can "register" their smart pointer classes by supplying an appropriate 155 <code class="computeroutput"><span class="identifier">get_pointer</span></code> overload, allowing 156 <code class="computeroutput"><span class="identifier">mem_fn</span></code> to recognize and support 157 them. 158 </p> 159<p> 160 <span class="emphasis"><em>[Note:</em></span> <code class="computeroutput"><span class="identifier">get_pointer</span></code> 161 is not restricted to return a pointer. Any object that can be used in a member 162 function call expression <code class="computeroutput"><span class="special">(</span><span class="identifier">x</span><span class="special">->*</span><span class="identifier">pmf</span><span class="special">)(...)</span></code> will work.<span class="emphasis"><em>]</em></span> 163 </p> 164<p> 165 <span class="emphasis"><em>[Note:</em></span> the library uses an unqualified call to <code class="computeroutput"><span class="identifier">get_pointer</span></code>. Therefore, it will find, through 166 argument-dependent lookup, <code class="computeroutput"><span class="identifier">get_pointer</span></code> 167 overloads that are defined in the same namespace as the corresponding smart 168 pointer class, in addition to any <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">get_pointer</span></code> 169 overloads.<span class="emphasis"><em>]</em></span> 170 </p> 171<p> 172 All function objects returned by <code class="computeroutput"><span class="identifier">mem_fn</span></code> 173 expose a <code class="computeroutput"><span class="identifier">result_type</span></code> typedef 174 that represents the return type of the member function. For data members, 175 <code class="computeroutput"><span class="identifier">result_type</span></code> is defined as the 176 type of the member. 177 </p> 178</div> 179<div class="section"> 180<div class="titlepage"><div><div><h2 class="title" style="clear: both"> 181<a name="mem_fn.faq"></a><a class="link" href="mem_fn.html#mem_fn.faq" title="Frequently Asked Questions">Frequently Asked Questions</a> 182</h2></div></div></div> 183<div class="section"> 184<div class="titlepage"><div><div><h3 class="title"> 185<a name="mem_fn.faq.can_mem_fn_be_used_instead_of_th"></a><a class="link" href="mem_fn.html#mem_fn.faq.can_mem_fn_be_used_instead_of_th" title="Can mem_fn be used instead of the standard std::mem_fun[_ref] adaptors?">Can <code class="computeroutput"><span class="identifier">mem_fn</span></code> be used instead of the standard <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">mem_fun</span><span class="special">[</span><span class="identifier">_ref</span><span class="special">]</span></code> 186 adaptors?</a> 187</h3></div></div></div> 188<p> 189 Yes. For simple uses, <code class="computeroutput"><span class="identifier">mem_fn</span></code> 190 provides additional functionality that the standard adaptors do not. Complicated 191 expressions that use <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">bind1st</span></code>, 192 <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">bind2nd</span></code> or <a href="http://www.boost.org/doc/libs/1_31_0/libs/compose/index.htm" target="_top">Boost.Compose</a> 193 along with the standard adaptors can be rewritten using <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span></code> 194 that automatically takes advantage of <code class="computeroutput"><span class="identifier">mem_fn</span></code>. 195 </p> 196</div> 197<div class="section"> 198<div class="titlepage"><div><div><h3 class="title"> 199<a name="mem_fn.faq.should_i_replace_every_occurence"></a><a class="link" href="mem_fn.html#mem_fn.faq.should_i_replace_every_occurence" title="Should I replace every occurence of std::mem_fun[_ref] with mem_fn in my existing code?">Should I 200 replace every occurence of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">mem_fun</span><span class="special">[</span><span class="identifier">_ref</span><span class="special">]</span></code> 201 with <code class="computeroutput"><span class="identifier">mem_fn</span></code> in my existing 202 code?</a> 203</h3></div></div></div> 204<p> 205 No, unless you have good reasons to do so. <code class="computeroutput"><span class="identifier">mem_fn</span></code> 206 is not 100% compatible with the standard adaptors, although it comes pretty 207 close. In particular, <code class="computeroutput"><span class="identifier">mem_fn</span></code> 208 does not return objects of type <code class="computeroutput"><span class="identifier">std</span><span class="special">::[</span><span class="identifier">const_</span><span class="special">]</span><span class="identifier">mem_fun</span><span class="special">[</span><span class="number">1</span><span class="special">][</span><span class="identifier">_ref</span><span class="special">]</span><span class="identifier">_t</span></code>, 209 as the standard adaptors do, and it is not possible to fully describe the 210 type of the first argument using the standard <code class="computeroutput"><span class="identifier">argument_type</span></code> 211 and <code class="computeroutput"><span class="identifier">first_argument_type</span></code> nested 212 typedefs. Libraries that need adaptable function objects in order to function 213 might not like <code class="computeroutput"><span class="identifier">mem_fn</span></code>. 214 </p> 215</div> 216<div class="section"> 217<div class="titlepage"><div><div><h3 class="title"> 218<a name="mem_fn.faq.does_mem_fn_work_with_com_method"></a><a class="link" href="mem_fn.html#mem_fn.faq.does_mem_fn_work_with_com_method" title="Does mem_fn work with COM methods?">Does <code class="computeroutput"><span class="identifier">mem_fn</span></code> work with COM methods?</a> 219</h3></div></div></div> 220<p> 221 Yes, if you <a class="link" href="mem_fn.html#mem_fn.implementation.stdcall" title="__stdcall, __cdecl, and __fastcall Support">`#define BOOST_MEM_FN_ENABLE_STDCALL</a>. 222 </p> 223</div> 224<div class="section"> 225<div class="titlepage"><div><div><h3 class="title"> 226<a name="mem_fn.faq.why_isn_t_boost_mem_fn_enable_st"></a><a class="link" href="mem_fn.html#mem_fn.faq.why_isn_t_boost_mem_fn_enable_st" title="Why isn't BOOST_MEM_FN_ENABLE_STDCALL defined automatically?">Why isn't 227 <code class="computeroutput"><span class="identifier">BOOST_MEM_FN_ENABLE_STDCALL</span></code> 228 defined automatically?</a> 229</h3></div></div></div> 230<p> 231 Non-portable extensions, in general, should default to off to prevent vendor 232 lock-in. Had <code class="computeroutput"><span class="identifier">BOOST_MEM_FN_ENABLE_STDCALL</span></code> 233 been defined automatically, you could have accidentally taken advantage of 234 it without realizing that your code is, perhaps, no longer portable. In addition, 235 it is possible for the default calling convention to be <code class="computeroutput"><span class="identifier">__stdcall</span></code>, 236 in which case enabling <code class="computeroutput"><span class="identifier">__stdcall</span></code> 237 support will result in duplicate definitions. 238 </p> 239</div> 240</div> 241<div class="section"> 242<div class="titlepage"><div><div><h2 class="title" style="clear: both"> 243<a name="mem_fn.interface"></a><a class="link" href="mem_fn.html#mem_fn.interface" title="Interface">Interface</a> 244</h2></div></div></div> 245<div class="section"> 246<div class="titlepage"><div><div><h3 class="title"> 247<a name="mem_fn.interface.synopsys"></a><a class="link" href="mem_fn.html#mem_fn.interface.synopsys" title="Synopsis">Synopsis</a> 248</h3></div></div></div> 249<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> 250<span class="special">{</span> 251 <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="identifier">T</span> <span class="special">*</span> <a class="link" href="mem_fn.html#get_pointer_1"><code class="computeroutput"><span class="identifier">get_pointer</span></code></a><span class="special">(</span><span class="identifier">T</span> <span class="special">*</span> <span class="identifier">p</span><span class="special">);</span> 252 253 <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="emphasis"><em>unspecified-1</em></span> <a class="link" href="mem_fn.html#mem_fn_1"><code class="computeroutput"><span class="identifier">mem_fn</span></code></a><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">());</span> 254 255 <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="emphasis"><em>unspecified-2</em></span> <a class="link" href="mem_fn.html#mem_fn_2"><code class="computeroutput"><span class="identifier">mem_fn</span></code></a><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">()</span> <span class="keyword">const</span><span class="special">);</span> 256 257 <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="emphasis"><em>unspecified-2-1</em></span> <a class="link" href="mem_fn.html#mem_fn_2_1"><code class="computeroutput"><span class="identifier">mem_fn</span></code></a><span class="special">(</span><span class="identifier">R</span> <span class="identifier">T</span><span class="special">::*</span><span class="identifier">pm</span><span class="special">);</span> 258 259 <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">></span> <span class="emphasis"><em>unspecified-3</em></span> <a class="link" href="mem_fn.html#mem_fn_3"><code class="computeroutput"><span class="identifier">mem_fn</span></code></a><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">(</span><span class="identifier">A1</span><span class="special">));</span> 260 261 <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">></span> <span class="emphasis"><em>unspecified-4</em></span> <a class="link" href="mem_fn.html#mem_fn_4"><code class="computeroutput"><span class="identifier">mem_fn</span></code></a><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">(</span><span class="identifier">A1</span><span class="special">)</span> <span class="keyword">const</span><span class="special">);</span> 262 263 <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A2</span><span class="special">></span> <span class="emphasis"><em>unspecified-5</em></span> <a class="link" href="mem_fn.html#mem_fn_5"><code class="computeroutput"><span class="identifier">mem_fn</span></code></a><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">(</span><span class="identifier">A1</span><span class="special">,</span> <span class="identifier">A2</span><span class="special">));</span> 264 265 <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A2</span><span class="special">></span> <span class="emphasis"><em>unspecified-6</em></span> <a class="link" href="mem_fn.html#mem_fn_6"><code class="computeroutput"><span class="identifier">mem_fn</span></code></a><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">(</span><span class="identifier">A1</span><span class="special">,</span> <span class="identifier">A2</span><span class="special">)</span> <span class="keyword">const</span><span class="special">);</span> 266 267 <span class="comment">// implementation defined number of additional overloads for more arguments</span> 268<span class="special">}</span> 269</pre> 270</div> 271<div class="section"> 272<div class="titlepage"><div><div><h3 class="title"> 273<a name="mem_fn.interface.common_requirements"></a><a class="link" href="mem_fn.html#mem_fn.interface.common_requirements" title="Common requirements">Common requirements</a> 274</h3></div></div></div> 275<p> 276 All <span class="emphasis"><em>unspecified-N</em></span> types mentioned in the Synopsis are 277 <span class="emphasis"><em>CopyConstructible</em></span> and <span class="emphasis"><em>Assignable</em></span>. 278 Their copy constructors and assignment operators do not throw exceptions. 279 <span class="emphasis"><em>unspecified-N</em></span><code class="computeroutput"><span class="special">::</span><span class="identifier">result_type</span></code> is defined as the return type 280 of the member function pointer passed as an argument to <code class="computeroutput"><span class="identifier">mem_fn</span></code> 281 (<code class="computeroutput"><span class="identifier">R</span></code> in the Synopsis.) <span class="emphasis"><em>unspecified-2-1</em></span><code class="computeroutput"><span class="special">::</span><span class="identifier">result_type</span></code> 282 is defined as <code class="computeroutput"><span class="identifier">R</span></code>. 283 </p> 284</div> 285<div class="section"> 286<div class="titlepage"><div><div><h3 class="title"> 287<a name="mem_fn.interface.get_pointer"></a><a class="link" href="mem_fn.html#mem_fn.interface.get_pointer" title="get_pointer"><code class="computeroutput"><span class="identifier">get_pointer</span></code></a> 288</h3></div></div></div> 289<a name="get_pointer_1"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="identifier">T</span> <span class="special">*</span> <span class="identifier">get_pointer</span><span class="special">(</span><span class="identifier">T</span> <span class="special">*</span> <span class="identifier">p</span><span class="special">)</span> 290</pre> 291<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 292<li class="listitem"> 293 <span class="emphasis"><em>Returns:</em></span> <code class="computeroutput"><span class="identifier">p</span></code>. 294 </li> 295<li class="listitem"> 296 <span class="emphasis"><em>Throws:</em></span> Nothing. 297 </li> 298</ul></div> 299</div> 300<div class="section"> 301<div class="titlepage"><div><div><h3 class="title"> 302<a name="mem_fn.interface.mem_fn"></a><a class="link" href="mem_fn.html#mem_fn.interface.mem_fn" title="mem_fn"><code class="computeroutput"><span class="identifier">mem_fn</span></code></a> 303</h3></div></div></div> 304<a name="mem_fn_1"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="emphasis"><em>unspecified-1</em></span> <span class="identifier">mem_fn</span><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">())</span> 305</pre> 306<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 307<li class="listitem"> 308 <span class="emphasis"><em>Returns:</em></span> a function object ϝ such that the 309 expression ϝ<code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">)</span></code> is equivalent to <code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">.*</span><span class="identifier">pmf</span><span class="special">)()</span></code> 310 when <code class="computeroutput"><span class="identifier">t</span></code> is an l-value 311 of type <code class="computeroutput"><span class="identifier">T</span></code> or derived, 312 <code class="computeroutput"><span class="special">(</span><span class="identifier">get_pointer</span><span class="special">(</span><span class="identifier">t</span><span class="special">)->*</span><span class="identifier">pmf</span><span class="special">)()</span></code> otherwise. 313 </li> 314<li class="listitem"> 315 <span class="emphasis"><em>Throws:</em></span> Nothing. 316 </li> 317</ul></div> 318<a name="mem_fn_2"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="emphasis"><em>unspecified-2</em></span> <span class="identifier">mem_fn</span><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">()</span> <span class="keyword">const</span><span class="special">)</span> 319</pre> 320<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 321<li class="listitem"> 322 <span class="emphasis"><em>Returns:</em></span> a function object ϝ such that the 323 expression ϝ<code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">)</span></code> is equivalent to <code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">.*</span><span class="identifier">pmf</span><span class="special">)()</span></code> 324 when <code class="computeroutput"><span class="identifier">t</span></code> is of type <code class="computeroutput"><span class="identifier">T</span></code> <span class="emphasis"><em>[</em></span><code class="computeroutput"><span class="keyword">const</span></code><span class="emphasis"><em>]</em></span> or derived, 325 <code class="computeroutput"><span class="special">(</span><span class="identifier">get_pointer</span><span class="special">(</span><span class="identifier">t</span><span class="special">)->*</span><span class="identifier">pmf</span><span class="special">)()</span></code> otherwise. 326 </li> 327<li class="listitem"> 328 <span class="emphasis"><em>Throws:</em></span> Nothing. 329 </li> 330</ul></div> 331<a name="mem_fn_2_1"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="emphasis"><em>unspecified-2-1</em></span> <span class="identifier">mem_fn</span><span class="special">(</span><span class="identifier">R</span> <span class="identifier">T</span><span class="special">::*</span><span class="identifier">pm</span><span class="special">)</span> 332</pre> 333<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 334<li class="listitem"> 335 <span class="emphasis"><em>Returns:</em></span> a function object ϝ such that the 336 expression ϝ<code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">)</span></code> is equivalent to <code class="computeroutput"><span class="identifier">t</span><span class="special">.*</span><span class="identifier">pm</span></code> 337 when <code class="computeroutput"><span class="identifier">t</span></code> is of type <code class="computeroutput"><span class="identifier">T</span></code> <span class="emphasis"><em>[</em></span><code class="computeroutput"><span class="keyword">const</span></code><span class="emphasis"><em>]</em></span> or derived, 338 <code class="computeroutput"><span class="identifier">get_pointer</span><span class="special">(</span><span class="identifier">t</span><span class="special">)->*</span><span class="identifier">pm</span></code> otherwise. 339 </li> 340<li class="listitem"> 341 <span class="emphasis"><em>Throws:</em></span> Nothing. 342 </li> 343</ul></div> 344<a name="mem_fn_3"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">></span> <span class="emphasis"><em>unspecified-3</em></span> <span class="identifier">mem_fn</span><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">(</span><span class="identifier">A1</span><span class="special">))</span> 345</pre> 346<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 347<li class="listitem"> 348 <span class="emphasis"><em>Returns:</em></span> a function object ϝ such that the 349 expression ϝ<code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">,</span> <span class="identifier">a1</span><span class="special">)</span></code> is equivalent to <code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">.*</span><span class="identifier">pmf</span><span class="special">)(</span><span class="identifier">a1</span><span class="special">)</span></code> 350 when <code class="computeroutput"><span class="identifier">t</span></code> is an l-value 351 of type <code class="computeroutput"><span class="identifier">T</span></code> or derived, 352 <code class="computeroutput"><span class="special">(</span><span class="identifier">get_pointer</span><span class="special">(</span><span class="identifier">t</span><span class="special">)->*</span><span class="identifier">pmf</span><span class="special">)(</span><span class="identifier">a1</span><span class="special">)</span></code> otherwise. 353 </li> 354<li class="listitem"> 355 <span class="emphasis"><em>Throws:</em></span> Nothing. 356 </li> 357</ul></div> 358<a name="mem_fn_4"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">></span> <span class="emphasis"><em>unspecified-4</em></span> <span class="identifier">mem_fn</span><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">(</span><span class="identifier">A1</span><span class="special">)</span> <span class="keyword">const</span><span class="special">)</span> 359</pre> 360<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 361<li class="listitem"> 362 <span class="emphasis"><em>Returns:</em></span> a function object ϝ such that the 363 expression ϝ<code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">,</span> <span class="identifier">a1</span><span class="special">)</span></code> is equivalent to <code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">.*</span><span class="identifier">pmf</span><span class="special">)(</span><span class="identifier">a1</span><span class="special">)</span></code> 364 when <code class="computeroutput"><span class="identifier">t</span></code> is of type <code class="computeroutput"><span class="identifier">T</span></code> <span class="emphasis"><em>[</em></span><code class="computeroutput"><span class="keyword">const</span></code><span class="emphasis"><em>]</em></span> or derived, 365 <code class="computeroutput"><span class="special">(</span><span class="identifier">get_pointer</span><span class="special">(</span><span class="identifier">t</span><span class="special">)->*</span><span class="identifier">pmf</span><span class="special">)(</span><span class="identifier">a1</span><span class="special">)</span></code> otherwise. 366 </li> 367<li class="listitem"> 368 <span class="emphasis"><em>Throws:</em></span> Nothing. 369 </li> 370</ul></div> 371<a name="mem_fn_5"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A2</span><span class="special">></span> <span class="emphasis"><em>unspecified-5</em></span> <span class="identifier">mem_fn</span><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">(</span><span class="identifier">A1</span><span class="special">,</span> <span class="identifier">A2</span><span class="special">))</span> 372</pre> 373<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 374<li class="listitem"> 375 <span class="emphasis"><em>Returns:</em></span> a function object ϝ such that the 376 expression ϝ<code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">,</span> <span class="identifier">a1</span><span class="special">,</span> <span class="identifier">a2</span><span class="special">)</span></code> is equivalent to <code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">.*</span><span class="identifier">pmf</span><span class="special">)(</span><span class="identifier">a1</span><span class="special">,</span> <span class="identifier">a2</span><span class="special">)</span></code> 377 when <code class="computeroutput"><span class="identifier">t</span></code> is an l-value 378 of type <code class="computeroutput"><span class="identifier">T</span></code> or derived, 379 <code class="computeroutput"><span class="special">(</span><span class="identifier">get_pointer</span><span class="special">(</span><span class="identifier">t</span><span class="special">)->*</span><span class="identifier">pmf</span><span class="special">)(</span><span class="identifier">a1</span><span class="special">,</span> <span class="identifier">a2</span><span class="special">)</span></code> otherwise. 380 </li> 381<li class="listitem"> 382 <span class="emphasis"><em>Throws:</em></span> Nothing. 383 </li> 384</ul></div> 385<a name="mem_fn_6"></a><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A2</span><span class="special">></span> <span class="emphasis"><em>unspecified-6</em></span> <span class="identifier">mem_fn</span><span class="special">(</span><span class="identifier">R</span> <span class="special">(</span><span class="identifier">T</span><span class="special">::*</span><span class="identifier">pmf</span><span class="special">)</span> <span class="special">(</span><span class="identifier">A1</span><span class="special">,</span> <span class="identifier">A2</span><span class="special">)</span> <span class="keyword">const</span><span class="special">)</span> 386</pre> 387<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 388<li class="listitem"> 389 <span class="emphasis"><em>Returns:</em></span> a function object ϝ such that the 390 expression ϝ<code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">,</span> <span class="identifier">a1</span><span class="special">,</span> <span class="identifier">a2</span><span class="special">)</span></code> is equivalent to <code class="computeroutput"><span class="special">(</span><span class="identifier">t</span><span class="special">.*</span><span class="identifier">pmf</span><span class="special">)(</span><span class="identifier">a1</span><span class="special">,</span> <span class="identifier">a2</span><span class="special">)</span></code> 391 when <code class="computeroutput"><span class="identifier">t</span></code> is of type <code class="computeroutput"><span class="identifier">T</span></code> <span class="emphasis"><em>[</em></span><code class="computeroutput"><span class="keyword">const</span></code><span class="emphasis"><em>]</em></span> or derived, 392 <code class="computeroutput"><span class="special">(</span><span class="identifier">get_pointer</span><span class="special">(</span><span class="identifier">t</span><span class="special">)->*</span><span class="identifier">pmf</span><span class="special">)(</span><span class="identifier">a1</span><span class="special">,</span> <span class="identifier">a2</span><span class="special">)</span></code> otherwise. 393 </li> 394<li class="listitem"> 395 <span class="emphasis"><em>Throws:</em></span> Nothing. 396 </li> 397</ul></div> 398</div> 399</div> 400<div class="section"> 401<div class="titlepage"><div><div><h2 class="title" style="clear: both"> 402<a name="mem_fn.implementation"></a><a class="link" href="mem_fn.html#mem_fn.implementation" title="Implementation">Implementation</a> 403</h2></div></div></div> 404<div class="section"> 405<div class="titlepage"><div><div><h3 class="title"> 406<a name="mem_fn.implementation.files"></a><a class="link" href="mem_fn.html#mem_fn.implementation.files" title="Files">Files</a> 407</h3></div></div></div> 408<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 409<li class="listitem"> 410 <a href="../../../../boost/mem_fn.hpp" target="_top">boost/mem_fn.hpp</a> (main 411 header) 412 </li> 413<li class="listitem"> 414 <a href="../../../../boost/bind/mem_fn_cc.hpp" target="_top">boost/bind/mem_fn_cc.hpp</a> 415 (used by <code class="computeroutput"><span class="identifier">mem_fn</span><span class="special">.</span><span class="identifier">hpp</span></code>, do not include directly) 416 </li> 417<li class="listitem"> 418 <a href="../../../../boost/bind/mem_fn_vw.hpp" target="_top">boost/bind/mem_fn_vw.hpp</a> 419 (used by <code class="computeroutput"><span class="identifier">mem_fn</span><span class="special">.</span><span class="identifier">hpp</span></code>, do not include directly) 420 </li> 421<li class="listitem"> 422 <a href="../../../../boost/bind/mem_fn_template.hpp" target="_top">boost/bind/mem_fn_template.hpp</a> 423 (used by <code class="computeroutput"><span class="identifier">mem_fn</span><span class="special">.</span><span class="identifier">hpp</span></code>, do not include directly) 424 </li> 425<li class="listitem"> 426 <a href="../../test/mem_fn_test.cpp" target="_top">libs/bind/test/mem_fn_test.cpp</a> 427 (test) 428 </li> 429<li class="listitem"> 430 <a href="../../test/mem_fn_derived_test.cpp" target="_top">libs/bind/test/mem_fn_derived_test.cpp</a> 431 (test with derived objects) 432 </li> 433<li class="listitem"> 434 <a href="../../test/mem_fn_fastcall_test.cpp" target="_top">libs/bind/test/mem_fn_fastcall_test.cpp</a> 435 (test for <code class="computeroutput"><span class="identifier">__fastcall</span></code>) 436 </li> 437<li class="listitem"> 438 <a href="../../test/mem_fn_stdcall_test.cpp" target="_top">libs/bind/test/mem_fn_stdcall_test.cpp</a> 439 (test for <code class="computeroutput"><span class="identifier">__stdcall</span></code>) 440 </li> 441<li class="listitem"> 442 <a href="../../test/mem_fn_void_test.cpp" target="_top">libs/bind/test/mem_fn_void_test.cpp</a> 443 (test for <code class="computeroutput"><span class="keyword">void</span></code> returns) 444 </li> 445</ul></div> 446</div> 447<div class="section"> 448<div class="titlepage"><div><div><h3 class="title"> 449<a name="mem_fn.implementation.dependencies"></a><a class="link" href="mem_fn.html#mem_fn.implementation.dependencies" title="Dependencies">Dependencies</a> 450</h3></div></div></div> 451<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> 452 <a href="../../../../libs/config/config.htm" target="_top">Boost.Config</a> 453 </li></ul></div> 454</div> 455<div class="section"> 456<div class="titlepage"><div><div><h3 class="title"> 457<a name="mem_fn.implementation.number_of_arguments"></a><a class="link" href="mem_fn.html#mem_fn.implementation.number_of_arguments" title="Number of Arguments">Number of 458 Arguments</a> 459</h3></div></div></div> 460<p> 461 This implementation supports member functions with up to eight arguments. 462 This is not an inherent limitation of the design, but an implementation detail. 463 </p> 464</div> 465<div class="section"> 466<div class="titlepage"><div><div><h3 class="title"> 467<a name="mem_fn.implementation.stdcall"></a><a class="link" href="mem_fn.html#mem_fn.implementation.stdcall" title="__stdcall, __cdecl, and __fastcall Support"><code class="computeroutput"><span class="identifier">__stdcall</span></code>, 468 <code class="computeroutput"><span class="identifier">__cdecl</span></code>, and <code class="computeroutput"><span class="identifier">__fastcall</span></code> Support</a> 469</h3></div></div></div> 470<p> 471 Some platforms allow several types of member functions that differ by their 472 calling convention (the rules by which the function is invoked: how are arguments 473 passed, how is the return value handled, and who cleans up the stack - if 474 any.) 475 </p> 476<p> 477 For example, Windows API functions and COM interface member functions use 478 a calling convention known as <code class="computeroutput"><span class="identifier">__stdcall</span></code>. 479 Borland VCL components use <code class="computeroutput"><span class="identifier">__fastcall</span></code>. 480 UDK, the component model of OpenOffice.org, uses <code class="computeroutput"><span class="identifier">__cdecl</span></code>. 481 </p> 482<p> 483 To use <code class="computeroutput"><span class="identifier">mem_fn</span></code> with <code class="computeroutput"><span class="identifier">__stdcall</span></code> member functions, <code class="computeroutput"><span class="preprocessor">#define</span></code> the macro <code class="computeroutput"><span class="identifier">BOOST_MEM_FN_ENABLE_STDCALL</span></code> 484 before including <code class="computeroutput"><span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">mem_fn</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>. 485 </p> 486<p> 487 To use <code class="computeroutput"><span class="identifier">mem_fn</span></code> with <code class="computeroutput"><span class="identifier">__fastcall</span></code> member functions, <code class="computeroutput"><span class="preprocessor">#define</span></code> the macro <code class="computeroutput"><span class="identifier">BOOST_MEM_FN_ENABLE_FASTCALL</span></code> 488 before including <code class="computeroutput"><span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">mem_fn</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>. 489 </p> 490<p> 491 To use <code class="computeroutput"><span class="identifier">mem_fn</span></code> with <code class="computeroutput"><span class="identifier">__cdecl</span></code> member functions, <code class="computeroutput"><span class="preprocessor">#define</span></code> the macro <code class="computeroutput"><span class="identifier">BOOST_MEM_FN_ENABLE_CDECL</span></code> 492 before including <code class="computeroutput"><span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">mem_fn</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>. 493 </p> 494<p> 495 <span class="bold"><strong>It is best to define these macros in the project options, 496 via <code class="computeroutput"><span class="special">-</span><span class="identifier">D</span></code> 497 on the command line, or as the first line in the translation unit (.cpp file) 498 where <code class="computeroutput"><span class="identifier">mem_fn</span></code> is used.</strong></span> 499 Not following this rule can lead to obscure errors when a header includes 500 <code class="computeroutput"><span class="identifier">mem_fn</span><span class="special">.</span><span class="identifier">hpp</span></code> before the macro has been defined. 501 </p> 502<p> 503 <span class="emphasis"><em>[Note:</em></span> this is a non-portable extension. It is not part 504 of the interface.<span class="emphasis"><em>]</em></span> 505 </p> 506<p> 507 <span class="emphasis"><em>[Note:</em></span> Some compilers provide only minimal support for 508 the <code class="computeroutput"><span class="identifier">__stdcall</span></code> keyword.<span class="emphasis"><em>]</em></span> 509 </p> 510</div> 511</div> 512<div class="section"> 513<div class="titlepage"><div><div><h2 class="title" style="clear: both"> 514<a name="mem_fn.acknowledgements"></a><a class="link" href="mem_fn.html#mem_fn.acknowledgements" title="Acknowledgements">Acknowledgements</a> 515</h2></div></div></div> 516<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 517<li class="listitem"> 518 Rene Jager's initial suggestion of using traits classes to make <code class="computeroutput"><span class="identifier">mem_fn</span></code> adapt to user-defined smart pointers 519 inspired the <code class="computeroutput"><span class="identifier">get_pointer</span></code>-based 520 design. 521 </li> 522<li class="listitem"> 523 Numerous improvements were suggested during the formal review period by 524 Richard Crossley, Jens Maurer, Ed Brey, and others. Review manager was 525 Darin Adler. 526 </li> 527<li class="listitem"> 528 Steve Anichini pointed out that COM interfaces use <code class="computeroutput"><span class="identifier">__stdcall</span></code>. 529 </li> 530<li class="listitem"> 531 Dave Abrahams modified <code class="computeroutput"><span class="identifier">bind</span></code> 532 and <code class="computeroutput"><span class="identifier">mem_fn</span></code> to support 533 <code class="computeroutput"><span class="keyword">void</span></code> returns on deficient 534 compilers. 535 </li> 536<li class="listitem"> 537 Daniel Boelzle pointed out that UDK uses <code class="computeroutput"><span class="identifier">__cdecl</span></code>. 538 </li> 539</ul></div> 540<p> 541 This documentation was ported to Quickbook by Agustín Bergé. 542 </p> 543</div> 544</div> 545<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 546<td align="left"><p><small>Last revised: August 11, 2020 at 15:01:56 GMT</small></p></td> 547<td align="right"><div class="copyright-footer"></div></td> 548</tr></table> 549<hr> 550<div class="spirit-nav"></div> 551</body> 552</html> 553