Compare commits

...

44 Commits

Author SHA1 Message Date
nobody
1aa02850b7 This commit was manufactured by cvs2svn to create tag
'Version_1_27_0'.

[SVN r12749]
2002-02-07 13:33:59 +00:00
nobody
fb72a35ee2 This commit was manufactured by cvs2svn to create branch 'RC_1_27_0'.
[SVN r12739]
2002-02-06 03:32:50 +00:00
Peter Dimov
b482c43928 Minor fixes.
[SVN r12688]
2002-02-04 13:56:30 +00:00
Darin Adler
9ca2e6f064 Fix some HTML errors.
[SVN r12649]
2002-02-02 19:02:53 +00:00
Peter Dimov
8ec63f5ca5 changed smart_ptr.hpp to shared_ptr.hpp
[SVN r12645]
2002-02-02 16:20:28 +00:00
Peter Dimov
866866c1df get_pointer overload for shared_ptr moved to shared_ptr.hpp
[SVN r12642]
2002-02-02 16:16:02 +00:00
Peter Dimov
3179474c0e Placeholders are now static only on MSVC.
[SVN r12630]
2002-02-02 12:16:57 +00:00
Peter Dimov
60a844927f Back to non-static, doesn't work for Borland PCHs, and generates annoying warnings.
[SVN r12600]
2002-01-31 12:46:33 +00:00
Peter Dimov
27c104f1fb Made the placeholders static.
[SVN r12599]
2002-01-31 12:34:58 +00:00
Peter Dimov
235feb0f62 _N placeholders moved to a separate header.
[SVN r12573]
2002-01-30 11:29:28 +00:00
Aleksey Gurtovoy
b2b06ea204 documented 'reference_wrapper' as Assignable
[SVN r12521]
2002-01-27 13:04:08 +00:00
Peter Dimov
d276e73ea0 Fixed a typo.
[SVN r12518]
2002-01-26 16:59:05 +00:00
Peter Dimov
70ec61e649 mem_fn now properly recognizes objects of derived classes.
[SVN r12498]
2002-01-25 13:43:54 +00:00
Peter Dimov
f37044ee57 _bi::bind_t no longer prevents assignment.
[SVN r12495]
2002-01-25 13:05:21 +00:00
Dave Abrahams
9d389aa1e3 account for new traits templates
[SVN r12468]
2002-01-23 21:04:00 +00:00
Peter Dimov
fc433254dc Tabs converted to spaces
[SVN r12338]
2002-01-17 16:02:41 +00:00
Peter Dimov
886d8b3079 SGI MIPSpro fix.
[SVN r11981]
2001-12-08 16:25:47 +00:00
Peter Dimov
b90421d2cd Troubleshooting section updated.
[SVN r11954]
2001-12-06 16:06:30 +00:00
Peter Dimov
55f974d0b8 Fixed internal compiler error on MSVC 6 with debug info enabled.
[SVN r11870]
2001-12-03 13:11:22 +00:00
Dave Abrahams
fe8a5204cc Re-enabled the void returns workarounds for MSVC, since they pass with VC6sp4. Added the void returns test to status/Jamfile.
Modified Files:
	boost/mem_fn.hpp status/Jamfile


[SVN r11863]
2001-12-02 21:51:14 +00:00
Peter Dimov
18f1b16872 Typos fixed.
[SVN r11845]
2001-12-01 13:02:09 +00:00
Peter Dimov
e1b4cd5dcf Temporarily disabled void returns on MSVC 6 to address internal compiler errors.
[SVN r11810]
2001-11-29 17:29:31 +00:00
Peter Dimov
00df4fc3bb #ifdef-ed out a test case for MWCW <= 7.1
[SVN r11809]
2001-11-29 17:02:39 +00:00
Peter Dimov
389154b530 Minor fix to address SGI MIPSpro regression failure.
[SVN r11807]
2001-11-29 15:10:05 +00:00
Peter Dimov
f6c95cf810 Mac Murrett added to Acknowledgments.
[SVN r11788]
2001-11-27 13:21:28 +00:00
Peter Dimov
b19b0e4d66 bind.html: Contents, FAQ, Dependencies added.
[SVN r11787]
2001-11-27 13:15:30 +00:00
Peter Dimov
16a07b2592 mem_fn FAQ updated.
[SVN r11786]
2001-11-27 11:54:25 +00:00
Peter Dimov
46a32f7547 visit_each support added.
[SVN r11784]
2001-11-26 13:28:16 +00:00
Peter Dimov
f17fa79f2b mem_fn.html: added Contents, FAQ, Dependencies, expanded Purpose.
[SVN r11777]
2001-11-24 17:03:11 +00:00
Peter Dimov
9cd7fd58a1 Changed first_argument_type to argument_type in [c]mf0
[SVN r11769]
2001-11-22 15:17:17 +00:00
Peter Dimov
5134310a5e More regression fixes
[SVN r11762]
2001-11-21 12:34:23 +00:00
Peter Dimov
463f513c23 Major fixes to address regression failures
[SVN r11746]
2001-11-20 17:05:56 +00:00
Dave Abrahams
ab0d3e94e1 Repairs for CWPro7
[SVN r11720]
2001-11-16 20:24:11 +00:00
Dave Abrahams
4251ab4e83 Nuked useless default arguments
[SVN r11719]
2001-11-16 20:23:51 +00:00
Peter Dimov
e3bd44aa77 Minor void return fixes (MSVC 6 on -W4, g++ 2.95.3)
[SVN r11706]
2001-11-15 14:50:04 +00:00
Dave Abrahams
03dba9a279 integrated void_returns work
[SVN r11703]
2001-11-14 23:47:09 +00:00
Dave Abrahams
7bdfb4acfc integrated void_returns work
[SVN r11702]
2001-11-14 23:39:32 +00:00
Dave Abrahams
27a040d7ee Pro7 support, better tests, less duplication
[SVN r11694]
2001-11-14 20:41:24 +00:00
Peter Dimov
223f7ef967 Added tests for void returns
[SVN r11676]
2001-11-14 15:17:11 +00:00
Peter Dimov
19d71a71f2 Attempt to work around Sun C++ 6u2 problem
[SVN r11671]
2001-11-13 19:07:25 +00:00
Peter Dimov
7776c66ffd Fixed a bug w/ adaptable function objects + nested binds, made ref<> return const
[SVN r11670]
2001-11-13 13:56:05 +00:00
Peter Dimov
b16c6a83dc Minor fixes
[SVN r11669]
2001-11-13 13:33:24 +00:00
Peter Dimov
0f75f57c30 '__stdcall support' section added.
[SVN r11651]
2001-11-10 20:19:40 +00:00
Peter Dimov
277aa14329 __stdcall support added.
[SVN r11649]
2001-11-10 19:18:58 +00:00
21 changed files with 3936 additions and 1337 deletions

533
bind.html
View File

@@ -7,18 +7,15 @@
<title>Boost: bind.hpp documentation</title>
</head>
<body bgcolor="White">
<body bgcolor="White" style="margin-left: 5%; margin-right: 5%;">
<table border="0" width="100%">
<tr>
<td width="277">
<img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" WIDTH="277" HEIGHT="86">
<img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" width="277" height="86">
</td>
<td align="center">
<table border="0">
<tr><td nowrap><h1>bind.hpp</h1></td></tr>
<tr><td align="right" nowrap><small>&nbsp;1.02.0001 (2001-10-18)</small></td></tr>
</table>
<h1>bind.hpp</h1>
</td>
</tr>
<tr>
@@ -26,15 +23,58 @@
</tr>
</table>
<h2>Files</h2>
<ul>
<li><a href="../../boost/bind.hpp">bind.hpp</a> (implementation)</li>
<li><a href="bind_test.cpp">bind_test.cpp</a> (test)</li>
<li><a href="bind_as_compose.cpp">bind_as_compose.cpp</a> (function composition example)</li>
<li><a href="bind_visitor.cpp">bind_visitor.cpp</a> (visitor example)</li>
</ul>
<h2>Contents</h2>
<h2>Purpose</h2>
<h3 style="margin-left: 20pt;"><a href="#Purpose">Purpose</a></h3>
<h4 style="margin-left: 40pt;"><a href="#with_functions">Using bind with functions and function pointers</a></h4>
<h4 style="margin-left: 40pt;"><a href="#with_function_objects">Using bind with function objects</a></h4>
<h4 style="margin-left: 40pt;"><a href="#with_member_functions">Using bind with member function pointers</a></h4>
<h4 style="margin-left: 40pt;"><a href="#nested_binds">Using nested binds for function composition</a></h4>
<h3 style="margin-left: 20pt;"><a href="#Examples">Examples</a></h3>
<h4 style="margin-left: 40pt;"><a href="#with_algorithms">Using bind with standard algorithms</a></h4>
<h4 style="margin-left: 40pt;"><a href="#with_boost_function">Using bind with Boost.Function</a></h4>
<h3 style="margin-left: 20pt;"><a href="#Limitations">Limitations</a></h3>
<h3 style="margin-left: 20pt;"><a href="#FAQ">Frequently Asked Questions</a></h3>
<h4 style="margin-left: 40pt;"><a href="#Q_doesnt_compile">Why doesn't this compile?</a></h4>
<h4 style="margin-left: 40pt;"><a href="#Q_does_compile">Why does this compile? It should not.</a></h4>
<h4 style="margin-left: 40pt;"><a href="#Q_forms">What is the difference between bind(f, ...) and bind&lt;R&gt;(f, ...)?</a></h4>
<h4 style="margin-left: 40pt;"><a href="#Q_win32_api">Does <b>bind</b> work with Windows API functions?</a></h4>
<h4 style="margin-left: 40pt;"><a href="#Q_com">Does <b>bind</b> work with COM methods?</a></h4>
<h4 style="margin-left: 40pt;"><a href="#Q_mac">Does <b>bind</b> work with Mac toolbox functions?</a></h4>
<h4 style="margin-left: 40pt;"><a href="#Q_auto_stdcall">Why doesn't <b>bind</b> automatically recognize nonstandard functions?</a></h4>
<h3 style="margin-left: 20pt;"><a href="#Troubleshooting">Troubleshooting</a></h3>
<h4 style="margin-left: 40pt;"><a href="#err_num_args">Incorrect number of arguments</a></h4>
<h4 style="margin-left: 40pt;"><a href="#err_signature">The function object cannot be called with the specified arguments</a></h4>
<h4 style="margin-left: 40pt;"><a href="#err_arg_access">Accessing an argument that does not exist</a></h4>
<h4 style="margin-left: 40pt;"><a href="#err_short_form">Inappropriate use of bind(f, ...)</a></h4>
<h4 style="margin-left: 40pt;"><a href="#err_long_form">Inappropriate use of bind&lt;R&gt;(f, ...)</a></h4>
<h4 style="margin-left: 40pt;"><a href="#err_nonstd">Binding a nonstandard function</a></h4>
<h4 style="margin-left: 40pt;"><a href="#err_const_arg"><b>const</b> in signatures</a></h4>
<h4 style="margin-left: 40pt;"><a href="#err_msvc_using">MSVC specific: using boost::bind;</a></h4>
<h4 style="margin-left: 40pt;"><a href="#err_msvc_class_template">MSVC specific: class templates shadow function templates</a></h4>
<h4 style="margin-left: 40pt;"><a href="#err_msvc_ellipsis">MSVC specific: ... in signatures treated as type</a></h4>
<h3 style="margin-left: 20pt;"><a href="#Interface">Interface</a></h3>
<h4 style="margin-left: 40pt;"><a href="#Synopsis">Synopsis</a></h4>
<h4 style="margin-left: 40pt;"><a href="#CommonRequirements">Common requirements</a></h4>
<h4 style="margin-left: 40pt;"><a href="#CommonDefinitions">Common definitions</a></h4>
<h4 style="margin-left: 40pt;"><a href="#bind">bind</a></h4>
<h3 style="margin-left: 20pt;"><a href="#Implementation">Implementation</a></h3>
<h4 style="margin-left: 40pt;"><a href="#Files">Files</a></h4>
<h4 style="margin-left: 40pt;"><a href="#Dependencies">Dependencies</a></h4>
<h4 style="margin-left: 40pt;"><a href="#NumberOfArguments">Number of Arguments</a></h4>
<h4 style="margin-left: 40pt;"><a href="#stdcall">&quot;__stdcall&quot; and &quot;pascal&quot; Support</a></h4>
<h4 style="margin-left: 40pt;"><a href="#BOOST_BIND">Using the BOOST_BIND macro</a></h4>
<h4 style="margin-left: 40pt;"><a href="#visit_each"><b>visit_each</b> support</a></h4>
<h3 style="margin-left: 20pt;"><a href="#Acknowledgements">Acknowledgements</a></h3>
<h2><a name="Purpose">Purpose</a></h2>
<p>
<b>boost::bind</b> is a generalization of the standard functions
@@ -46,7 +86,7 @@ in particular, it does not need the <b>result_type</b>,
<b>first_argument_type</b> and <b>second_argument_type</b> standard typedefs.
</p>
<h3>Using bind with functions and function pointers</h3>
<h3><a name="with_functions">Using bind with functions and function pointers</a></h3>
<p>
Given these definitions:
@@ -81,15 +121,15 @@ library primitives:
</p>
<pre>
std::bind1st(std::ptr_fun(f), 5)(x);
std::bind2nd(std::ptr_fun(f), 5)(x);
</pre>
<p>
<b>bind</b> covers the functionality of <b>std::bind2nd</b> as well:
<b>bind</b> covers the functionality of <b>std::bind1st</b> as well:
</p>
<pre>
std::bind2nd(std::ptr_fun(f), 5)(x); // f(5, x)
std::bind1st(std::ptr_fun(f), 5)(x); // f(5, x)
bind(f, 5, _1)(x); // f(5, x)
</pre>
@@ -140,7 +180,7 @@ int i = 5;
bind(f, ref(i), _1);
</pre>
<h3>Using bind with function objects</h3>
<h3><a name="with_function_objects">Using bind with function objects</a></h3>
<p>
<b>bind</b> is not limited to functions; it accepts arbitrary function objects.
@@ -171,14 +211,14 @@ the explicit return type can be omitted:
<pre>
int x = 8;
bind(std::less&lt;int&gt;, _1, 9)(x); // x < 9
bind(std::less&lt;int&gt;(), _1, 9)(x); // x < 9
</pre>
<p>
[Note: the ability to omit the return type is not available on all compilers.]
</p>
<h3>Using bind with member function pointers</h3>
<h3><a name="with_member_functions">Using bind with member function pointers</a></h3>
<p>
Pointers to member functions are not function objects, because they do not
@@ -228,7 +268,7 @@ int i = 5;
bind(&amp;X::f, ref(x), _1)(i); // x.f(i)
bind(&amp;X::f, &x, _1)(i); // (&x)->f(i)
bind(&amp;X::f, &amp;x, _1)(i); // (&amp;x)->f(i)
bind(&amp;X::f, x, _1)(i); // (<i>internal copy of x</i>).f(i)
@@ -245,7 +285,7 @@ the function object retains a reference to its instance of <b>X</b> and will
remain valid even when <b>p</b> goes out of scope or is <b>reset()</b>.
</p>
<h3>Using nested binds for function composition</h3>
<h3><a name="nested_binds">Using nested binds for function composition</a></h3>
<p>
Some of the arguments passed to <b>bind</b> may be nested <b>bind</b> expressions
@@ -290,7 +330,9 @@ int main()
}
</pre>
<h3>Example: using bind with standard algorithms</h3>
<h2><a name="Examples">Examples</a></h2>
<h3><a name="with_algorithms">Using bind with standard algorithms</a></h3>
<pre>
class image;
@@ -323,7 +365,7 @@ void render(image &amp; target)
}
</pre>
<h3>Example: using bind with Boost.Function</h3>
<h3><a name="with_boost_function">Using bind with Boost.Function</a></h3>
<pre>
class button
@@ -351,7 +393,7 @@ void connect()
}
</pre>
<h3>Limitations</h3>
<h3><a name="Limitations">Limitations</a></h3>
<p>
The function objects generated by <b>bind</b> take their arguments by
@@ -395,9 +437,295 @@ partially ordered.
corresponding issue</a> has not been resolved yet.]
</p>
<h2>Interface</h2>
<h2><a name="FAQ">Frequently Asked Questions</a></h2>
<h3>Synopsis</h3>
<h3><a name="Q_doesnt_compile">Why doesn't this compile?</a></h3>
<p>
See the <a href="#Troubleshooting">dedicated Troubleshooting section</a>.
</p>
<h3><a name="Q_does_compile">Why does this compile? It should not.</a></h3>
<p>
Probably because you used the general bind&lt;R&gt;(f, ...) syntax, thereby
instructing <b>bind</b> to not &quot;inspect&quot; <b>f</b> to detect arity
and return type errors.
</p>
<h3><a name="Q_forms">What is the difference between bind(f, ...) and bind&lt;R&gt;(f, ...)?</a></h3>
<p>
The first form instructs <b>bind</b> to inspect the type of <b>f</b> in order
to determine its arity (number of arguments) and return type. Arity errors
will be detected at &quot;bind time&quot;. This syntax, of course, places some
requirements on <b>f</b>. It must be a function, function pointer, member
function pointer, or a function object that defines a nested type named
<b>result_type</b>; in short, it must be something that <b>bind</b> can
recognize.
</p>
<p>
The second form instructs <b>bind</b> to <b>not</b> attempt to recognize the
type of <b>f</b>. It is generally used with function objects that do not, or
cannot, expose <b>result_type</b>, but it can also be used with nonstandard
functions. For example, the current implementation does not automatically
recognize variable-argument functions like <b>printf</b>, so you will have to
use <tt>bind&lt;int&gt;(printf, ...)</tt>.
</p>
<p>
Another important factor to consider is that compilers without partial template
specialization or function template partial ordering support cannot handle the
first form when <b>f</b> is a function object, and in most cases will not handle
the second form when <b>f</b> is a function (pointer) or a member function pointer.
</p>
<h3><a name="Q_win32_api">Does <b>bind</b> work with Windows API functions?</a></h3>
<p>
Yes, if you <a href="#stdcall">#define BOOST_BIND_ENABLE_STDCALL</a>.
An alternative is to treat the function as a
<a href="#with_function_objects">generic function object</a> and use the
bind&lt;R&gt;(f, ...) syntax.
</p>
<h3><a name="Q_com">Does <b>bind</b> work with COM methods?</a></h3>
<p>
Yes, if you <a href="#stdcall">#define BOOST_MEM_FN_ENABLE_STDCALL</a>.
</p>
<h3><a name="Q_mac">Does <b>bind</b> work with Mac toolbox functions?</a></h3>
<p>
Yes, if you <a href="#stdcall">#define BOOST_BIND_ENABLE_PASCAL</a>.
An alternative is to treat the function as a
<a href="#with_function_objects">generic function object</a> and use the
bind&lt;R&gt;(f, ...) syntax.
</p>
<h3><a name="Q_auto_stdcall">Why doesn't <b>bind</b> automatically recognize nonstandard functions?</a></h3>
<p>
Non-portable extensions, in general, should default to off to prevent vendor
lock-in. Had the <a href="#stdcall">appropriate macros</a> been defined
automatically, you could
have accidentally taken advantage of them without realizing that your code is,
perhaps, no longer portable. In addition, some compilers have the option to
make <b>__stdcall</b> their default calling convention, in which case no
separate support would be necessary.
</p>
<h2><a name="Troubleshooting">Troubleshooting</a></h2>
<h3><a name="err_num_args">Incorrect number of arguments</a></h3>
<p>
In a bind(f, a1, a2, ..., aN) expression, the function object <b>f</b> must
be able to take exactly <b>N</b> arguments. This error is normally detected
at &quot;bind time&quot;; in other words, the compilation error is reported
on the line where bind() is invoked:
</p>
<pre>
int f(int, int);
int main()
{
boost::bind(f, 1); // error, f takes two arguments
boost::bind(f, 1, 2); // OK
}
</pre>
<p>
A common variation of this error is to forget that member functions have an
implicit &quot;this&quot; argument:
</p>
<pre>
struct X
{
int f(int);
}
int main()
{
boost::bind(&amp;X::f, 1); // error, X::f takes two arguments
boost::bind(&amp;X::f, <b>_1</b>, 1); // OK
}
</pre>
<h3><a name="err_signature">The function object cannot be called with the specified arguments</a></h3>
<p>
As in normal function calls, the function object that is bound must be
compatible with the argument list. The incompatibility will usually be
detected by the compiler at &quot;call time&quot; and the result is
typically an error in <b>bind.hpp</b> on a line that looks like:
</p>
<pre>
return f(a[a1_], a[a2_]);
</pre>
<p>
An example of this kind of error:
</p>
<pre>
int f(int);
int main()
{
boost::bind(f, &quot;incompatible&quot;); // OK so far, no call
boost::bind(f, &quot;incompatible&quot;)(); // error, &quot;incompatible&quot; is not an int
boost::bind(f, _1); // OK
boost::bind(f, _1)(&quot;incompatible&quot;); // error, &quot;incompatible&quot; is not an int
}
</pre>
<h3><a name="err_arg_access">Accessing an argument that does not exist</a></h3>
<p>
The placeholder <b>_N</b> selects the argument at position <b>N</b> from the
argument list passed at &quot;call time.&quot; Naturally, it is an error to
attempt to access beyond the end of this list:
</p>
<pre>
int f(int);
int main()
{
boost::bind(f, _1); // OK
boost::bind(f, _1)(); // error, there is no argument number 1
}
</pre>
<p>
The error is usually reported in <b>bind.hpp</b>, at a line similar to:
</p>
<pre>
return f(a[a1_]);
</pre>
<p>
When emulating <b>std::bind1st(f, a)</b>, a common mistake of this category
is to type <b>bind(f, a, _2)</b> instead of the correct <b>bind(f, a, _1)</b>.
</p>
<h3><a name="err_short_form">Inappropriate use of bind(f, ...)</a></h3>
<p>
The bind(f, a1, a2, ..., aN) <a href="#Q_forms">form</a> causes automatic
recognition of the type of <b>f</b>. It will not work with arbitrary
function objects; <b>f</b> must be a function or a member function pointer.
</p>
<p>
It is possible to use this form with function objects that define
<b>result_type</b>, but <b>only on compilers</b> that support partial
specialization and partial ordering. In particular, MSVC up to version 7.0
does not support this syntax for function objects.
</p>
<h3><a name="err_long_form">Inappropriate use of bind&lt;R&gt;(f, ...)</a></h3>
<p>
The bind&lt;R&gt;(f, a1, a2, ..., aN) <a href="#Q_forms">form</a> supports
arbitrary function objects.
</p>
<p>
It is possible (but not recommended) to use this form with functions or
member function pointers, but <b>only on compilers</b> that support partial
ordering. In particular, MSVC up to version 7.0 does not fully support this
syntax for functions and member function pointers.
</p>
<h3><a name="err_nonstd">Binding a nonstandard function</a></h3>
<p>
(to be written)
</p>
<h3><a name="err_const_arg"><b>const</b> in signatures</a></h3>
<p>
Some compilers, including MSVC 6.0 and Borland C++ 5.5.1, have problems
with the top-level <b>const</b> in function signatures:
</p>
<pre>
int f(int const);
int main()
{
boost::bind(f, 1); // error
}
</pre>
<p>
Workaround: remove the <b>const</b> qualifier from the argument.
</p>
<h3><a name="err_msvc_using">MSVC specific: using boost::bind;</a></h3>
<p>
On MSVC (up to version 7.0), when <b>boost::bind</b> is brought into scope
with an using declaration:
</p>
<pre>
using boost::bind;
</pre>
<p>
the syntax <b>bind&lt;R&gt;(...)</b> does not work. Workaround: either use the
qualified name, <b>boost::bind</b>, or use an using directive instead:
</p>
<pre>
using namespace boost;
</pre>
<h3><a name="err_msvc_class_template">MSVC specific: class templates shadow function templates</a></h3>
<p>
On MSVC (up to version 7.0), a nested class template named <b>bind</b> will
shadow the function template <b>boost::bind</b>, breaking the
<b>bind&lt;R&gt;(...)</b> syntax. Unfortunately, some libraries contain nested
class templates named <b>bind</b> (ironically, such code is often an MSVC
specific workaround.) You may try to patch the library in question or contact
its author/maintainer. The other option is use the
<a href="#BOOST_BIND">BOOST_BIND</a> macro to rename <b>bind</b>.
</p>
<h3><a name="err_msvc_ellipsis">MSVC specific: ... in signatures treated as type</a></h3>
<p>
MSVC (up to version 7.0) treats the ellipsis in a variable argument function
(such as <b>std::printf</b>) as a type. Therefore, it will accept the
(incorrect in the current implementation) form:
</p>
<pre>
bind(printf, &quot;%s\n&quot;, _1);
</pre>
<p>
and will reject the correct version:
</p>
<pre>
bind&lt;int&gt;(printf, &quot;%s\n&quot;, _1);
</pre>
<h2><a name="Interface">Interface</a></h2>
<h3><a name="Synopsis">Synopsis</a></h3>
<pre>
namespace boost
@@ -453,7 +781,7 @@ namespace
}
</pre>
<h3>Common requirements</h3>
<h3><a name="CommonRequirements">Common requirements</a></h3>
<p>
All <tt><i>implementation-defined-N</i></tt> types returned by <b>bind</b> are
@@ -466,7 +794,7 @@ All <tt><i>implementation-defined-placeholder-N</i></tt> types are
<b>CopyConstructible</b>. Their copy constructors do not throw exceptions.
</p>
<h3>Common definitions</h3>
<h3><a name="CommonDefinitions">Common definitions</a></h3>
<p>
The function &micro;(x, v<sub>1</sub>, v<sub>2</sub>, ..., v<sub>m</sub>), where m is a nonnegative integer, is defined as:
@@ -482,7 +810,7 @@ when <tt>x</tt> is (a copy of) a function object returned by <b>bind</b>;</li>
</ul>
<h3>bind</h3>
<h3><a name="bind">bind</a></h3>
<h4><a name="bind_1">template&lt;class R, class F&gt; <i>implementation-defined-1</i> bind(F f)</a></h4>
@@ -520,7 +848,7 @@ implicitly converted to <b>R</b>.
implicitly converted to <b>R</b>.
</p>
<p>
<b>Throws:</b> Nothing unless the copy constructors of <b>F</b> and <b>A1</b> throw an exception.
<b>Throws:</b> Nothing unless the copy constructors of <b>F</b> or <b>A1</b> throw an exception.
</p>
<h4><a name="bind_3_1">template&lt;class F, class A1&gt; <i>implementation-defined-3-1</i> bind(F f, A1 a1)</a></h4>
@@ -561,7 +889,7 @@ implicitly converted to <b>R</b>.
implicitly converted to <b>R</b>.
</p>
<p>
<b>Throws:</b> Nothing unless the copy constructors of <b>F</b>, <b>A1</b> and <b>A2</b> throw an exception.
<b>Throws:</b> Nothing unless the copy constructors of <b>F</b>, <b>A1</b> or <b>A2</b> throw an exception.
</p>
<h4><a name="bind_7_1">template&lt;class F, class A1, class A2&gt; <i>implementation-defined-7-1</i> bind(F f, A1 a1, A2 a2)</a></h4>
@@ -578,7 +906,7 @@ implicitly converted to <b>R</b>.
<tt><b>f</b>(&micro;(<b>a1</b>, v<sub>1</sub>, v<sub>2</sub>, ..., v<sub>m</sub>), &micro;(<b>a2</b>, v<sub>1</sub>, v<sub>2</sub>, ..., v<sub>m</sub>))</tt>.
</p>
<p>
<b>Throws:</b> Nothing unless the copy constructors of <b>A1</b> and <b>A2</b> throw an exception.
<b>Throws:</b> Nothing unless the copy constructors of <b>A1</b> or <b>A2</b> throw an exception.
</p>
<h4><a name="bind_9">template&lt;class R, class T, class B1, class A1, class A2&gt; <i>implementation-defined-9</i> bind(R (T::*f) (B1), A1 a1, A2 a2)</a></h4>
@@ -593,7 +921,29 @@ implicitly converted to <b>R</b>.
<b>Effects:</b> equivalent to <tt>bind&lt;R&gt;(<a href="mem_fn.html">boost::mem_fn</a>(f), a1, a2);</tt>
</p>
<h2>Implementation</h2>
<h2><a name="Implementation">Implementation</a></h2>
<h3><a name="Files">Files</a></h3>
<ul>
<li><a href="../../boost/bind.hpp">boost/bind.hpp</a> (main header)</li>
<li><a href="../../boost/bind/bind_cc.hpp">boost/bind/bind_cc.hpp</a> (used by bind.hpp, do not include directly)
<li><a href="../../boost/bind/bind_mf_cc.hpp">boost/bind/bind_mf_cc.hpp</a> (used by bind.hpp, do not include directly)
<li><a href="../../boost/bind/bind_template.hpp">boost/bind/bind_template.hpp</a> (used by bind.hpp, do not include directly)
<li><a href="bind_test.cpp">libs/bind/bind_test.cpp</a> (test)</li>
<li><a href="bind_as_compose.cpp">libs/bind/bind_as_compose.cpp</a> (function composition example)</li>
<li><a href="bind_visitor.cpp">libs/bind/bind_visitor.cpp</a> (visitor example)</li>
<li><a href="bind_stdcall_test.cpp">libs/bind/bind_stdcall_test.cpp</a> (test with __stdcall functions)</li>
<li><a href="bind_stdcall_mf_test.cpp">libs/bind/bind_stdcall_mf_test.cpp</a> (test with __stdcall member functions)</li>
</ul>
<h3><a name="Dependencies">Dependencies</a></h3>
<ul>
<li><a href="../config/config.htm">Boost.Config</a>
<li><a href="ref.html">boost/ref.hpp</a>
<li><a href="mem_fn.html">boost/mem_fn.hpp</a>
</ul>
<h3><a name="NumberOfArguments">Number of Arguments</a></h3>
<p>
This implementation supports function objects with up to nine arguments.
@@ -601,68 +951,54 @@ This is an implementation detail, not an inherent limitation of the
design.
</p>
<h3>Void returns</h3>
<h3><a name="stdcall">&quot;__stdcall&quot; and &quot;pascal&quot; Support</a></h3>
<p>
The following C++ code:
</p>
<pre>
void f();
void g()
{
return f();
}
</pre>
<p>
is legal; in fact it was deliberately made legal in order to support
forwarding functions that return <b>void</b>.
Some platforms allow several types of (member) functions that differ by their
<b>calling convention</b> (the rules by which the function is invoked: how
are arguments passed, how is the return value handled, and who cleans up the
stack - if any.)
</p>
<p>
Unfortunately, some compilers have not caught up with the C++ Standard yet
and do not allow void returns. This implementation of <b>bind</b> will not
work for function pointers, member function pointers or function objects that
return <b>void</b> if the compiler does not support the feature. A possible
workaround is to change the return type of the function object in question
from <b>void</b> to <b>int</b> and return a dummy value of 0.
For example, Windows API functions and COM interface member functions use a
calling convention known as <b>__stdcall</b>. Mac toolbox functions use a
<b>pascal</b> calling convention.
</p>
<h3>MSVC specific problems and workarounds</h3>
<p>
Microsoft Visual C++ (up to version 7.0) does not fully support the
<b>bind&lt;R&gt;(...)</b>
syntax required by the library when arbitrary function objects are bound.
The first problem is that when <b>boost::bind</b> is brought into scope
with an <b>using declaration</b>:
To use <b>bind</b> with <b>__stdcall</b> functions, <b>#define</b> the macro
<b>BOOST_BIND_ENABLE_STDCALL</b> before including <b>&lt;boost/bind.hpp&gt;</b>.
</p>
<pre>
using boost::bind;
</pre>
<p>
the syntax above does not work. Workaround: either use the qualified name,
<b>boost::bind</b>, or use an <b>using directive</b> instead:
To use <b>bind</b> with <b>__stdcall</b> <b>member</b> functions, <b>#define</b> the
macro <b>BOOST_MEM_FN_ENABLE_STDCALL</b> before including <b>&lt;boost/bind.hpp&gt;</b>.
</p>
<pre>
using namespace boost;
</pre>
<p>
To use <b>bind</b> with <b>pascal</b> functions, <b>#define</b> the macro
<b>BOOST_BIND_ENABLE_PASCAL</b> before including <b>&lt;boost/bind.hpp&gt;</b>.
</p>
<p>
The second problem is that some libraries contain nested class templates
named <b>bind</b> (ironically, such code is often an MSVC specific
workaround.) Due to some quirks with the parser, such a class template
breaks the <b>bind&lt;R&gt;(...)</b> syntax, even when the name <b>bind</b>
is fully qualified. You may try to patch the library in question or contact
its author/maintainer. The other option is to define the macro
<b>BOOST_BIND</b> to something other than <b>bind</b> (before the inclusion of
<b>&lt;boost/bind.hpp&gt;</b>) and use this identifier throughout your code
wherever you'd normally use <b>bind</b>.
[Note: this is a non-portable extension. It is not part of the interface.]
</p>
<p>
[Note: Some compilers provide only minimal support for the <b>__stdcall</b> keyword.]
</p>
<h3><a name="BOOST_BIND">Using the BOOST_BIND macro</a></h3>
<p>
A <a href="#err_msvc_class_template">bug in MSVC (up to version 7.0)</a>
causes <b>boost::bind</b> to be incompatible
with libraries that contain nested class templates named <b>bind</b>. To work
around this problem, <b>#define</b> the macro <b>BOOST_BIND</b> to something
other than <b>bind</b> (before the inclusion of <b>&lt;boost/bind.hpp&gt;</b>)
and use this identifier throughout your code wherever you'd normally use
<b>bind</b>.
</p>
<p style="color: Red;">
@@ -671,33 +1007,18 @@ interface, and is not guaranteed to work on other compilers, or persist between
library versions. In short, don't use it unless you absolutely have to.]
</p>
<h3>Visitor support</h3>
<p style="color: Red;">
[Note: this is an experimental feature. It may evolve over time
when other libraries start to exploit it; or it may be removed altogether if
no other library needs it. It is not part of the interface.]
</p>
<h3><a name="visit_each"><b>visit_each</b> support</a></h3>
<p>
For better integration with other libraries, the function objects returned by
<b>bind</b> define a member function
</p>
<pre>
template&lt;class Visitor&gt; void accept(Visitor &amp; v);
</pre>
<p>
that applies <b>v</b>, as a function object, to its internal state. Using
<b>accept</b> is implementation-specific and not intended for end users.
Function objects returned by <b>bind</b> support the experimental and
undocumented, as of yet, <b>visit_each</b> enumeration interface.
</p>
<p>
See <a href="bind_visitor.cpp">bind_visitor.cpp</a> for an example.
</p>
<h2>Acknowledgements</h2>
<h2><a name="Acknowledgements">Acknowledgements</a></h2>
<p>
Earlier efforts that have influenced the library design:
@@ -737,6 +1058,16 @@ Dave Abrahams fixed a MSVC-specific conflict between <b>bind</b> and the
<a href="../utility\iterator_adaptors.htm">iterator adaptors library</a>.
</p>
<p>
Dave Abrahams modified <b>bind</b> and <b>mem_fn</b> to support void returns
on deficient compilers.
</p>
<p>
Mac Murrett contributed the &quot;pascal&quot; support enabled by
BOOST_BIND_ENABLE_PASCAL.
</p>
<p><br><br><br><small>Copyright &copy; 2001 by Peter Dimov and Multi Media
Ltd. Permission to copy, use, modify, sell and distribute this document is
granted provided this copyright notice appears in all copies. This document

165
bind_stdcall_mf_test.cpp Normal file
View File

@@ -0,0 +1,165 @@
#if defined(_MSC_VER) && !defined(__ICL)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion
#pragma warning(disable: 4514) // unreferenced inline removed
#endif
//
// bind_stdcall_mf_test.cpp - test for bind.hpp + __stdcall (member functions)
//
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
#define BOOST_MEM_FN_ENABLE_STDCALL
#include <boost/bind.hpp>
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(push, 3)
#endif
#include <iostream>
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(pop)
#endif
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
struct X
{
mutable unsigned int hash;
X(): hash(0) {}
int __stdcall f0() { f1(17); return 0; }
int __stdcall g0() const { g1(17); return 0; }
int __stdcall f1(int a1) { hash = (hash * 17041 + a1) % 32768; return 0; }
int __stdcall g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; }
int __stdcall f2(int a1, int a2) { f1(a1); f1(a2); return 0; }
int __stdcall g2(int a1, int a2) const { g1(a1); g1(a2); return 0; }
int __stdcall f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; }
int __stdcall g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; }
int __stdcall f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; }
int __stdcall g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; }
int __stdcall f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; }
int __stdcall g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; }
int __stdcall f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; }
int __stdcall g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; }
int __stdcall f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; }
int __stdcall g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; }
int __stdcall f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; }
int __stdcall g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; }
};
void member_function_test()
{
using namespace boost;
X x;
// 0
bind(&X::f0, &x)();
bind(&X::f0, ref(x))();
bind(&X::g0, &x)();
bind(&X::g0, x)();
bind(&X::g0, ref(x))();
// 1
bind(&X::f1, &x, 1)();
bind(&X::f1, ref(x), 1)();
bind(&X::g1, &x, 1)();
bind(&X::g1, x, 1)();
bind(&X::g1, ref(x), 1)();
// 2
bind(&X::f2, &x, 1, 2)();
bind(&X::f2, ref(x), 1, 2)();
bind(&X::g2, &x, 1, 2)();
bind(&X::g2, x, 1, 2)();
bind(&X::g2, ref(x), 1, 2)();
// 3
bind(&X::f3, &x, 1, 2, 3)();
bind(&X::f3, ref(x), 1, 2, 3)();
bind(&X::g3, &x, 1, 2, 3)();
bind(&X::g3, x, 1, 2, 3)();
bind(&X::g3, ref(x), 1, 2, 3)();
// 4
bind(&X::f4, &x, 1, 2, 3, 4)();
bind(&X::f4, ref(x), 1, 2, 3, 4)();
bind(&X::g4, &x, 1, 2, 3, 4)();
bind(&X::g4, x, 1, 2, 3, 4)();
bind(&X::g4, ref(x), 1, 2, 3, 4)();
// 5
bind(&X::f5, &x, 1, 2, 3, 4, 5)();
bind(&X::f5, ref(x), 1, 2, 3, 4, 5)();
bind(&X::g5, &x, 1, 2, 3, 4, 5)();
bind(&X::g5, x, 1, 2, 3, 4, 5)();
bind(&X::g5, ref(x), 1, 2, 3, 4, 5)();
// 6
bind(&X::f6, &x, 1, 2, 3, 4, 5, 6)();
bind(&X::f6, ref(x), 1, 2, 3, 4, 5, 6)();
bind(&X::g6, &x, 1, 2, 3, 4, 5, 6)();
bind(&X::g6, x, 1, 2, 3, 4, 5, 6)();
bind(&X::g6, ref(x), 1, 2, 3, 4, 5, 6)();
// 7
bind(&X::f7, &x, 1, 2, 3, 4, 5, 6, 7)();
bind(&X::f7, ref(x), 1, 2, 3, 4, 5, 6, 7)();
bind(&X::g7, &x, 1, 2, 3, 4, 5, 6, 7)();
bind(&X::g7, x, 1, 2, 3, 4, 5, 6, 7)();
bind(&X::g7, ref(x), 1, 2, 3, 4, 5, 6, 7)();
// 8
bind(&X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8)();
bind(&X::f8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)();
bind(&X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8)();
bind(&X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8)();
bind(&X::g8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)();
BOOST_TEST( x.hash == 23558 );
}
int test_main(int, char * [])
{
member_function_test();
return 0;
}

110
bind_stdcall_test.cpp Normal file
View File

@@ -0,0 +1,110 @@
#if defined(_MSC_VER) && !defined(__ICL)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion
#pragma warning(disable: 4514) // unreferenced inline removed
#endif
//
// bind_stdcall_test.cpp - test for bind.hpp + __stdcall (free functions)
//
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
#define BOOST_BIND_ENABLE_STDCALL
#include <boost/bind.hpp>
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(push, 3)
#endif
#include <iostream>
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(pop)
#endif
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
//
long __stdcall f_0()
{
return 17041L;
}
long __stdcall f_1(long a)
{
return a;
}
long __stdcall f_2(long a, long b)
{
return a + 10 * b;
}
long __stdcall f_3(long a, long b, long c)
{
return a + 10 * b + 100 * c;
}
long __stdcall f_4(long a, long b, long c, long d)
{
return a + 10 * b + 100 * c + 1000 * d;
}
long __stdcall f_5(long a, long b, long c, long d, long e)
{
return a + 10 * b + 100 * c + 1000 * d + 10000 * e;
}
long __stdcall f_6(long a, long b, long c, long d, long e, long f)
{
return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f;
}
long __stdcall f_7(long a, long b, long c, long d, long e, long f, long g)
{
return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g;
}
long __stdcall f_8(long a, long b, long c, long d, long e, long f, long g, long h)
{
return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h;
}
long __stdcall f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i)
{
return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i;
}
void function_test()
{
using namespace boost;
int const i = 1;
BOOST_TEST( bind(f_0)(i) == 17041L );
BOOST_TEST( bind(f_1, _1)(i) == 1L );
BOOST_TEST( bind(f_2, _1, 2)(i) == 21L );
BOOST_TEST( bind(f_3, _1, 2, 3)(i) == 321L );
BOOST_TEST( bind(f_4, _1, 2, 3, 4)(i) == 4321L );
BOOST_TEST( bind(f_5, _1, 2, 3, 4, 5)(i) == 54321L );
BOOST_TEST( bind(f_6, _1, 2, 3, 4, 5, 6)(i) == 654321L );
BOOST_TEST( bind(f_7, _1, 2, 3, 4, 5, 6, 7)(i) == 7654321L );
BOOST_TEST( bind(f_8, _1, 2, 3, 4, 5, 6, 7, 8)(i) == 87654321L );
BOOST_TEST( bind(f_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i) == 987654321L );
}
int test_main(int, char * [])
{
function_test();
return 0;
}

View File

@@ -8,9 +8,8 @@
//
// bind_test.cpp - monolithic test for bind.hpp
//
// Version 1.00.0002 (2001-09-02)
//
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
// Copyright (c) 2001 David Abrahams
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
@@ -20,8 +19,18 @@
#include <boost/bind.hpp>
#include <boost/ref.hpp>
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(push, 3)
#endif
#include <iostream>
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(pop)
#endif
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
@@ -77,6 +86,58 @@ long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i)
return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i;
}
long global_result;
void fv_0()
{
global_result = 17041L;
}
void fv_1(long a)
{
global_result = a;
}
void fv_2(long a, long b)
{
global_result = a + 10 * b;
}
void fv_3(long a, long b, long c)
{
global_result = a + 10 * b + 100 * c;
}
void fv_4(long a, long b, long c, long d)
{
global_result = a + 10 * b + 100 * c + 1000 * d;
}
void fv_5(long a, long b, long c, long d, long e)
{
global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e;
}
void fv_6(long a, long b, long c, long d, long e, long f)
{
global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f;
}
void fv_7(long a, long b, long c, long d, long e, long f, long g)
{
global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g;
}
void fv_8(long a, long b, long c, long d, long e, long f, long g, long h)
{
global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h;
}
void fv_9(long a, long b, long c, long d, long e, long f, long g, long h, long i)
{
global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i;
}
void function_test()
{
using namespace boost;
@@ -93,6 +154,17 @@ void function_test()
BOOST_TEST( bind(f_7, _1, 2, 3, 4, 5, 6, 7)(i) == 7654321L );
BOOST_TEST( bind(f_8, _1, 2, 3, 4, 5, 6, 7, 8)(i) == 87654321L );
BOOST_TEST( bind(f_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i) == 987654321L );
BOOST_TEST( (bind(fv_0)(i), (global_result == 17041L)) );
BOOST_TEST( (bind(fv_1, _1)(i), (global_result == 1L)) );
BOOST_TEST( (bind(fv_2, _1, 2)(i), (global_result == 21L)) );
BOOST_TEST( (bind(fv_3, _1, 2, 3)(i), (global_result == 321L)) );
BOOST_TEST( (bind(fv_4, _1, 2, 3, 4)(i), (global_result == 4321L)) );
BOOST_TEST( (bind(fv_5, _1, 2, 3, 4, 5)(i), (global_result == 54321L)) );
BOOST_TEST( (bind(fv_6, _1, 2, 3, 4, 5, 6)(i), (global_result == 654321L)) );
BOOST_TEST( (bind(fv_7, _1, 2, 3, 4, 5, 6, 7)(i), (global_result == 7654321L)) );
BOOST_TEST( (bind(fv_8, _1, 2, 3, 4, 5, 6, 7, 8)(i), (global_result == 87654321L)) );
BOOST_TEST( (bind(fv_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i), (global_result == 987654321L)) );
}
//
@@ -102,6 +174,7 @@ struct Y
short operator()(short & r) const { return ++r; }
int operator()(int a, int b) const { return a + 10 * b; }
long operator() (long a, long b, long c) const { return a + 10 * b + 100 * c; }
void operator() (long a, long b, long c, long d) const { global_result = a + 10 * b + 100 * c + 1000 * d; }
};
void function_object_test()
@@ -116,6 +189,13 @@ void function_object_test()
BOOST_TEST( bind<short>(Y(), ref(i))() == 8 );
BOOST_TEST( bind<int>(Y(), i, _1)(k) == 38 );
BOOST_TEST( bind<long>(Y(), i, _1, 9)(k) == 938 );
#if !defined(__MWERKS__) || (__MWERKS__ > 0x2406) // Fails for this version of the compiler.
bind<void>(Y(), i, _1, 9, 4)(k);
BOOST_TEST( global_result == 4938 );
#endif
}
//
@@ -171,6 +251,40 @@ struct X
int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; }
};
struct V
{
mutable unsigned int hash;
V(): hash(0) {}
void f0() { f1(17); }
void g0() const { g1(17); }
void f1(int a1) { hash = (hash * 17041 + a1) % 32768; }
void g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; }
void f2(int a1, int a2) { f1(a1); f1(a2); }
void g2(int a1, int a2) const { g1(a1); g1(a2); }
void f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); }
void g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); }
void f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); }
void g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); }
void f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); }
void g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); }
void f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); }
void g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); }
void f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); }
void g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); }
void f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); }
void g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); }
};
void member_function_test()
{
using namespace boost;
@@ -261,6 +375,96 @@ void member_function_test()
BOOST_TEST( x.hash == 23558 );
}
void member_function_void_test()
{
using namespace boost;
V v;
// 0
bind(&V::f0, &v)();
bind(&V::f0, ref(v))();
bind(&V::g0, &v)();
bind(&V::g0, v)();
bind(&V::g0, ref(v))();
// 1
bind(&V::f1, &v, 1)();
bind(&V::f1, ref(v), 1)();
bind(&V::g1, &v, 1)();
bind(&V::g1, v, 1)();
bind(&V::g1, ref(v), 1)();
// 2
bind(&V::f2, &v, 1, 2)();
bind(&V::f2, ref(v), 1, 2)();
bind(&V::g2, &v, 1, 2)();
bind(&V::g2, v, 1, 2)();
bind(&V::g2, ref(v), 1, 2)();
// 3
bind(&V::f3, &v, 1, 2, 3)();
bind(&V::f3, ref(v), 1, 2, 3)();
bind(&V::g3, &v, 1, 2, 3)();
bind(&V::g3, v, 1, 2, 3)();
bind(&V::g3, ref(v), 1, 2, 3)();
// 4
bind(&V::f4, &v, 1, 2, 3, 4)();
bind(&V::f4, ref(v), 1, 2, 3, 4)();
bind(&V::g4, &v, 1, 2, 3, 4)();
bind(&V::g4, v, 1, 2, 3, 4)();
bind(&V::g4, ref(v), 1, 2, 3, 4)();
// 5
bind(&V::f5, &v, 1, 2, 3, 4, 5)();
bind(&V::f5, ref(v), 1, 2, 3, 4, 5)();
bind(&V::g5, &v, 1, 2, 3, 4, 5)();
bind(&V::g5, v, 1, 2, 3, 4, 5)();
bind(&V::g5, ref(v), 1, 2, 3, 4, 5)();
// 6
bind(&V::f6, &v, 1, 2, 3, 4, 5, 6)();
bind(&V::f6, ref(v), 1, 2, 3, 4, 5, 6)();
bind(&V::g6, &v, 1, 2, 3, 4, 5, 6)();
bind(&V::g6, v, 1, 2, 3, 4, 5, 6)();
bind(&V::g6, ref(v), 1, 2, 3, 4, 5, 6)();
// 7
bind(&V::f7, &v, 1, 2, 3, 4, 5, 6, 7)();
bind(&V::f7, ref(v), 1, 2, 3, 4, 5, 6, 7)();
bind(&V::g7, &v, 1, 2, 3, 4, 5, 6, 7)();
bind(&V::g7, v, 1, 2, 3, 4, 5, 6, 7)();
bind(&V::g7, ref(v), 1, 2, 3, 4, 5, 6, 7)();
// 8
bind(&V::f8, &v, 1, 2, 3, 4, 5, 6, 7, 8)();
bind(&V::f8, ref(v), 1, 2, 3, 4, 5, 6, 7, 8)();
bind(&V::g8, &v, 1, 2, 3, 4, 5, 6, 7, 8)();
bind(&V::g8, v, 1, 2, 3, 4, 5, 6, 7, 8)();
bind(&V::g8, ref(v), 1, 2, 3, 4, 5, 6, 7, 8)();
BOOST_TEST( v.hash == 23558 );
}
void nested_bind_test()
{
using namespace boost;
@@ -273,16 +477,25 @@ void nested_bind_test()
BOOST_TEST( bind(f_2, bind(f_1, _1), bind(f_1, _1))(x) == 11L );
BOOST_TEST( bind(f_2, bind(f_1, _1), bind(f_1, _2))(x, y) == 21L );
BOOST_TEST( bind(f_1, bind(f_0))() == 17041L );
BOOST_TEST( (bind(fv_1, bind(f_1, _1))(x), (global_result == 1L)) );
BOOST_TEST( (bind(fv_1, bind(f_2, _1, _2))(x, y), (global_result == 21L)) );
BOOST_TEST( (bind(fv_2, bind(f_1, _1), bind(f_1, _1))(x), (global_result == 11L)) );
BOOST_TEST( (bind(fv_2, bind(f_1, _1), bind(f_1, _2))(x, y), (global_result == 21L)) );
BOOST_TEST( (bind(fv_1, bind(f_0))(), (global_result == 17041L)) );
}
int test_main(int, char * [])
{
function_test();
function_object_test();
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
adaptable_function_object_test();
#endif
member_function_test();
member_function_void_test();
nested_bind_test();
return 0;

View File

@@ -8,8 +8,6 @@
//
// bind_visitor.cpp - tests bind.hpp with a visitor
//
// Version 1.00.0003 (2001-10-18)
//
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
//
// Permission to copy, use, modify, sell and distribute this software
@@ -20,42 +18,48 @@
#include <boost/bind.hpp>
#include <boost/ref.hpp>
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(push, 3)
#endif
#include <iostream>
#include <typeinfo>
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(pop)
#endif
// default implementation of visit_each
namespace boost
{
template<class V, class T> void visit_each(V & v, T const & t, long)
{
v(t, 0);
}
}
// visitor
int hash = 0;
struct ref_visitor
struct visitor
{
template<class R, class F, class L> void operator()(boost::_bi::bind_t<R, F, L> const & b) const
{
b.accept(*this);
}
template<class T> void operator()(boost::reference_wrapper<T> const & r) const
template<class T> void operator()(boost::reference_wrapper<T> const & r, int) const
{
std::cout << "Reference to " << typeid(T).name() << " @ " << &r.get() << " (with value " << r.get() << ")\n";
hash += r.get();
}
#ifndef BOOST_MSVC
template<class T> void operator()(T const &) const
template<class T> void operator()(T const &, long) const
{
std::cout << "Catch-all: " << typeid(T).name() << '\n';
std::cout << "Value of type " << typeid(T).name() << '\n';
++hash;
}
#else
void operator()(...) const
{
}
#endif
};
int f(int & i, int & j)
int f(int & i, int & j, int)
{
++i;
--j;
@@ -83,7 +87,8 @@ int main()
{
using namespace boost;
ref_visitor()(bind<int>(bind(f, ref(x), _1), ref(y)));
visitor v;
visit_each(v, bind<int>(bind(f, ref(x), _1, 42), ref(y)), 0);
return detect_errors(hash == 9);
return detect_errors(hash == 12);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,30 @@
#ifndef BOOST_BIND_ARG_HPP_INCLUDED
#define BOOST_BIND_ARG_HPP_INCLUDED
#if _MSC_VER >= 1020
#pragma once
#endif
//
// bind/arg.hpp
//
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// See http://www.boost.org/libs/bind/bind.html for documentation.
//
namespace boost
{
template<int I> class arg
{
};
} // namespace boost
#endif // #ifndef BOOST_BIND_ARG_HPP_INCLUDED

View File

@@ -0,0 +1,118 @@
//
// bind/bind_cc.hpp - support for different calling conventions
//
// Do not include this header directly.
//
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// See http://www.boost.org/libs/bind/bind.html for documentation.
//
template<class R>
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (), _bi::list0>
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) ())
{
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) ();
typedef _bi::list0 list_type;
return _bi::bind_t<R, F, list_type> (f, list_type());
}
template<class R, class B1, class A1>
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1), typename _bi::list_av_1<A1>::type>
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1), A1 a1)
{
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1);
typedef typename _bi::list_av_1<A1>::type list_type;
return _bi::bind_t<R, F, list_type> (f, list_type(a1));
}
template<class R, class B1, class B2, class A1, class A2>
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2), typename _bi::list_av_2<A1, A2>::type>
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2), A1 a1, A2 a2)
{
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2);
typedef typename _bi::list_av_2<A1, A2>::type list_type;
return _bi::bind_t<R, F, list_type> (f, list_type(a1, a2));
}
template<class R,
class B1, class B2, class B3,
class A1, class A2, class A3>
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3), typename _bi::list_av_3<A1, A2, A3>::type>
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3), A1 a1, A2 a2, A3 a3)
{
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3);
typedef typename _bi::list_av_3<A1, A2, A3>::type list_type;
return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3));
}
template<class R,
class B1, class B2, class B3, class B4,
class A1, class A2, class A3, class A4>
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4), typename _bi::list_av_4<A1, A2, A3, A4>::type>
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4), A1 a1, A2 a2, A3 a3, A4 a4)
{
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4);
typedef typename _bi::list_av_4<A1, A2, A3, A4>::type list_type;
return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4));
}
template<class R,
class B1, class B2, class B3, class B4, class B5,
class A1, class A2, class A3, class A4, class A5>
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4, B5), typename _bi::list_av_5<A1, A2, A3, A4, A5>::type>
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4, B5), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
{
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4, B5);
typedef typename _bi::list_av_5<A1, A2, A3, A4, A5>::type list_type;
return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5));
}
template<class R,
class B1, class B2, class B3, class B4, class B5, class B6,
class A1, class A2, class A3, class A4, class A5, class A6>
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4, B5, B6), typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type>
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4, B5, B6), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
{
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4, B5, B6);
typedef typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type list_type;
return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6));
}
template<class R,
class B1, class B2, class B3, class B4, class B5, class B6, class B7,
class A1, class A2, class A3, class A4, class A5, class A6, class A7>
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4, B5, B6, B7), typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type>
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4, B5, B6, B7), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
{
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4, B5, B6, B7);
typedef typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type list_type;
return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7));
}
template<class R,
class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8,
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4, B5, B6, B7, B8), typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type>
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4, B5, B6, B7, B8), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
{
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4, B5, B6, B7, B8);
typedef typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8));
}
template<class R,
class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8, class B9,
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
_bi::bind_t<R, BOOST_BIND_ST R (BOOST_BIND_CC *) (B1, B2, B3, B4, B5, B6, B7, B8, B9), typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
BOOST_BIND(BOOST_BIND_ST R (BOOST_BIND_CC *f) (B1, B2, B3, B4, B5, B6, B7, B8, B9), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
{
typedef BOOST_BIND_ST R (BOOST_BIND_CC *F) (B1, B2, B3, B4, B5, B6, B7, B8, B9);
typedef typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
return _bi::bind_t<R, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
}

View File

@@ -0,0 +1,228 @@
//
// bind/bind_mf_cc.hpp - support for different calling conventions
//
// Do not include this header directly.
//
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// See http://www.boost.org/libs/bind/bind.html for documentation.
//
// 0
template<class R, class T,
class A1>
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf0)<R, T>, typename _bi::list_av_1<A1>::type>
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (), A1 a1)
{
typedef _mfi::BOOST_BIND_MF_NAME(mf0)<R, T> F;
typedef typename _bi::list_av_1<A1>::type list_type;
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1));
}
template<class R, class T,
class A1>
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf0)<R, T>, typename _bi::list_av_1<A1>::type>
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) () const, A1 a1)
{
typedef _mfi::BOOST_BIND_MF_NAME(cmf0)<R, T> F;
typedef typename _bi::list_av_1<A1>::type list_type;
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1));
}
// 1
template<class R, class T,
class B1,
class A1, class A2>
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf1)<R, T, B1>, typename _bi::list_av_2<A1, A2>::type>
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1), A1 a1, A2 a2)
{
typedef _mfi::BOOST_BIND_MF_NAME(mf1)<R, T, B1> F;
typedef typename _bi::list_av_2<A1, A2>::type list_type;
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2));
}
template<class R, class T,
class B1,
class A1, class A2>
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf1)<R, T, B1>, typename _bi::list_av_2<A1, A2>::type>
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1) const, A1 a1, A2 a2)
{
typedef _mfi::BOOST_BIND_MF_NAME(cmf1)<R, T, B1> F;
typedef typename _bi::list_av_2<A1, A2>::type list_type;
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2));
}
// 2
template<class R, class T,
class B1, class B2,
class A1, class A2, class A3>
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf2)<R, T, B1, B2>, typename _bi::list_av_3<A1, A2, A3>::type>
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2), A1 a1, A2 a2, A3 a3)
{
typedef _mfi::BOOST_BIND_MF_NAME(mf2)<R, T, B1, B2> F;
typedef typename _bi::list_av_3<A1, A2, A3>::type list_type;
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3));
}
template<class R, class T,
class B1, class B2,
class A1, class A2, class A3>
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf2)<R, T, B1, B2>, typename _bi::list_av_3<A1, A2, A3>::type>
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2) const, A1 a1, A2 a2, A3 a3)
{
typedef _mfi::BOOST_BIND_MF_NAME(cmf2)<R, T, B1, B2> F;
typedef typename _bi::list_av_3<A1, A2, A3>::type list_type;
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3));
}
// 3
template<class R, class T,
class B1, class B2, class B3,
class A1, class A2, class A3, class A4>
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf3)<R, T, B1, B2, B3>, typename _bi::list_av_4<A1, A2, A3, A4>::type>
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3), A1 a1, A2 a2, A3 a3, A4 a4)
{
typedef _mfi::BOOST_BIND_MF_NAME(mf3)<R, T, B1, B2, B3> F;
typedef typename _bi::list_av_4<A1, A2, A3, A4>::type list_type;
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4));
}
template<class R, class T,
class B1, class B2, class B3,
class A1, class A2, class A3, class A4>
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf3)<R, T, B1, B2, B3>, typename _bi::list_av_4<A1, A2, A3, A4>::type>
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3) const, A1 a1, A2 a2, A3 a3, A4 a4)
{
typedef _mfi::BOOST_BIND_MF_NAME(cmf3)<R, T, B1, B2, B3> F;
typedef typename _bi::list_av_4<A1, A2, A3, A4>::type list_type;
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4));
}
// 4
template<class R, class T,
class B1, class B2, class B3, class B4,
class A1, class A2, class A3, class A4, class A5>
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf4)<R, T, B1, B2, B3, B4>, typename _bi::list_av_5<A1, A2, A3, A4, A5>::type>
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
{
typedef _mfi::BOOST_BIND_MF_NAME(mf4)<R, T, B1, B2, B3, B4> F;
typedef typename _bi::list_av_5<A1, A2, A3, A4, A5>::type list_type;
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5));
}
template<class R, class T,
class B1, class B2, class B3, class B4,
class A1, class A2, class A3, class A4, class A5>
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf4)<R, T, B1, B2, B3, B4>, typename _bi::list_av_5<A1, A2, A3, A4, A5>::type>
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4) const, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
{
typedef _mfi::BOOST_BIND_MF_NAME(cmf4)<R, T, B1, B2, B3, B4> F;
typedef typename _bi::list_av_5<A1, A2, A3, A4, A5>::type list_type;
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5));
}
// 5
template<class R, class T,
class B1, class B2, class B3, class B4, class B5,
class A1, class A2, class A3, class A4, class A5, class A6>
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf5)<R, T, B1, B2, B3, B4, B5>, typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type>
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
{
typedef _mfi::BOOST_BIND_MF_NAME(mf5)<R, T, B1, B2, B3, B4, B5> F;
typedef typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type list_type;
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6));
}
template<class R, class T,
class B1, class B2, class B3, class B4, class B5,
class A1, class A2, class A3, class A4, class A5, class A6>
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf5)<R, T, B1, B2, B3, B4, B5>, typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type>
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5) const, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
{
typedef _mfi::BOOST_BIND_MF_NAME(cmf5)<R, T, B1, B2, B3, B4, B5> F;
typedef typename _bi::list_av_6<A1, A2, A3, A4, A5, A6>::type list_type;
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6));
}
// 6
template<class R, class T,
class B1, class B2, class B3, class B4, class B5, class B6,
class A1, class A2, class A3, class A4, class A5, class A6, class A7>
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf6)<R, T, B1, B2, B3, B4, B5, B6>, typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type>
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
{
typedef _mfi::BOOST_BIND_MF_NAME(mf6)<R, T, B1, B2, B3, B4, B5, B6> F;
typedef typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type list_type;
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7));
}
template<class R, class T,
class B1, class B2, class B3, class B4, class B5, class B6,
class A1, class A2, class A3, class A4, class A5, class A6, class A7>
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf6)<R, T, B1, B2, B3, B4, B5, B6>, typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type>
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6) const, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
{
typedef _mfi::BOOST_BIND_MF_NAME(cmf6)<R, T, B1, B2, B3, B4, B5, B6> F;
typedef typename _bi::list_av_7<A1, A2, A3, A4, A5, A6, A7>::type list_type;
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7));
}
// 7
template<class R, class T,
class B1, class B2, class B3, class B4, class B5, class B6, class B7,
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf7)<R, T, B1, B2, B3, B4, B5, B6, B7>, typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type>
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
{
typedef _mfi::BOOST_BIND_MF_NAME(mf7)<R, T, B1, B2, B3, B4, B5, B6, B7> F;
typedef typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8));
}
template<class R, class T,
class B1, class B2, class B3, class B4, class B5, class B6, class B7,
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf7)<R, T, B1, B2, B3, B4, B5, B6, B7>, typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type>
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7) const, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
{
typedef _mfi::BOOST_BIND_MF_NAME(cmf7)<R, T, B1, B2, B3, B4, B5, B6, B7> F;
typedef typename _bi::list_av_8<A1, A2, A3, A4, A5, A6, A7, A8>::type list_type;
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8));
}
// 8
template<class R, class T,
class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8,
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(mf8)<R, T, B1, B2, B3, B4, B5, B6, B7, B8>, typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7, B8), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
{
typedef _mfi::BOOST_BIND_MF_NAME(mf8)<R, T, B1, B2, B3, B4, B5, B6, B7, B8> F;
typedef typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
}
template<class R, class T,
class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8,
class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
_bi::bind_t<R, _mfi::BOOST_BIND_MF_NAME(cmf8)<R, T, B1, B2, B3, B4, B5, B6, B7, B8>, typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type>
BOOST_BIND(R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5, B6, B7, B8) const, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
{
typedef _mfi::BOOST_BIND_MF_NAME(cmf8)<R, T, B1, B2, B3, B4, B5, B6, B7, B8> F;
typedef typename _bi::list_av_9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::type list_type;
return _bi::bind_t<R, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
}

View File

@@ -0,0 +1,157 @@
//
// bind/bind_template.hpp
//
// Do not include this header directly.
//
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// See http://www.boost.org/libs/bind/bind.html for documentation.
//
typedef typename result_traits<R, F>::type result_type;
result_type operator()()
{
list0 a;
BOOST_BIND_EVALUATE;
}
result_type operator()() const
{
list0 a;
BOOST_BIND_EVALUATE;
}
template<class A1> result_type operator()(A1 & a1)
{
list1<A1 &> a(a1);
BOOST_BIND_EVALUATE;
}
template<class A1> result_type operator()(A1 & a1) const
{
list1<A1 &> a(a1);
BOOST_BIND_EVALUATE;
}
template<class A1, class A2> result_type operator()(A1 & a1, A2 & a2)
{
list2<A1 &, A2 &> a(a1, a2);
BOOST_BIND_EVALUATE;
}
template<class A1, class A2> result_type operator()(A1 & a1, A2 & a2) const
{
list2<A1 &, A2 &> a(a1, a2);
BOOST_BIND_EVALUATE;
}
template<class A1, class A2, class A3> result_type operator()(A1 & a1, A2 & a2, A3 & a3)
{
list3<A1 &, A2 &, A3 &> a(a1, a2, a3);
BOOST_BIND_EVALUATE;
}
template<class A1, class A2, class A3> result_type operator()(A1 & a1, A2 & a2, A3 & a3) const
{
list3<A1 &, A2 &, A3 &> a(a1, a2, a3);
BOOST_BIND_EVALUATE;
}
template<class A1, class A2, class A3, class A4> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4)
{
list4<A1 &, A2 &, A3 &, A4 &> a(a1, a2, a3, a4);
BOOST_BIND_EVALUATE;
}
template<class A1, class A2, class A3, class A4> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4) const
{
list4<A1 &, A2 &, A3 &, A4 &> a(a1, a2, a3, a4);
BOOST_BIND_EVALUATE;
}
template<class A1, class A2, class A3, class A4, class A5> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5)
{
list5<A1 &, A2 &, A3 &, A4 &, A5 &> a(a1, a2, a3, a4, a5);
BOOST_BIND_EVALUATE;
}
template<class A1, class A2, class A3, class A4, class A5> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5) const
{
list5<A1 &, A2 &, A3 &, A4 &, A5 &> a(a1, a2, a3, a4, a5);
BOOST_BIND_EVALUATE;
}
template<class A1, class A2, class A3, class A4, class A5, class A6> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6)
{
list6<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &> a(a1, a2, a3, a4, a5, a6);
BOOST_BIND_EVALUATE;
}
template<class A1, class A2, class A3, class A4, class A5, class A6> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6) const
{
list6<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &> a(a1, a2, a3, a4, a5, a6);
BOOST_BIND_EVALUATE;
}
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7)
{
list7<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &> a(a1, a2, a3, a4, a5, a6, a7);
BOOST_BIND_EVALUATE;
}
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7) const
{
list7<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &> a(a1, a2, a3, a4, a5, a6, a7);
BOOST_BIND_EVALUATE;
}
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8)
{
list8<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &, A8 &> a(a1, a2, a3, a4, a5, a6, a7, a8);
BOOST_BIND_EVALUATE;
}
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8) const
{
list8<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &, A8 &> a(a1, a2, a3, a4, a5, a6, a7, a8);
BOOST_BIND_EVALUATE;
}
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8, A9 & a9)
{
list9<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &, A8 &, A9 &> a(a1, a2, a3, a4, a5, a6, a7, a8, a9);
BOOST_BIND_EVALUATE;
}
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8, A9 & a9) const
{
list9<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &, A8 &, A9 &> a(a1, a2, a3, a4, a5, a6, a7, a8, a9);
BOOST_BIND_EVALUATE;
}
template<class A> result_type eval(A & a)
{
BOOST_BIND_EVALUATE;
}
template<class A> result_type eval(A & a) const
{
BOOST_BIND_EVALUATE;
}
template<class V> void accept(V & v) const
{
BOOST_BIND_VISIT_EACH(v, f_, 0);
l_.accept(v);
}
private:
F f_;
L l_;

View File

@@ -0,0 +1,104 @@
//
// bind/mem_fn_cc.hpp - support for different calling conventions
//
// Do not include this header directly.
//
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// See http://www.boost.org/libs/bind/mem_fn.html for documentation.
//
template<class R, class T> _mfi::BOOST_MEM_FN_NAME(mf0)<R, T> mem_fn(R (BOOST_MEM_FN_CC T::*f) ())
{
return _mfi::BOOST_MEM_FN_NAME(mf0)<R, T>(f);
}
template<class R, class T> _mfi::BOOST_MEM_FN_NAME(cmf0)<R, T> mem_fn(R (BOOST_MEM_FN_CC T::*f) () const)
{
return _mfi::BOOST_MEM_FN_NAME(cmf0)<R, T>(f);
}
template<class R, class T, class A1> _mfi::BOOST_MEM_FN_NAME(mf1)<R, T, A1> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1))
{
return _mfi::BOOST_MEM_FN_NAME(mf1)<R, T, A1>(f);
}
template<class R, class T, class A1> _mfi::BOOST_MEM_FN_NAME(cmf1)<R, T, A1> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1) const)
{
return _mfi::BOOST_MEM_FN_NAME(cmf1)<R, T, A1>(f);
}
template<class R, class T, class A1, class A2> _mfi::BOOST_MEM_FN_NAME(mf2)<R, T, A1, A2> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2))
{
return _mfi::BOOST_MEM_FN_NAME(mf2)<R, T, A1, A2>(f);
}
template<class R, class T, class A1, class A2> _mfi::BOOST_MEM_FN_NAME(cmf2)<R, T, A1, A2> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2) const)
{
return _mfi::BOOST_MEM_FN_NAME(cmf2)<R, T, A1, A2>(f);
}
template<class R, class T, class A1, class A2, class A3> _mfi::BOOST_MEM_FN_NAME(mf3)<R, T, A1, A2, A3> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3))
{
return _mfi::BOOST_MEM_FN_NAME(mf3)<R, T, A1, A2, A3>(f);
}
template<class R, class T, class A1, class A2, class A3> _mfi::BOOST_MEM_FN_NAME(cmf3)<R, T, A1, A2, A3> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3) const)
{
return _mfi::BOOST_MEM_FN_NAME(cmf3)<R, T, A1, A2, A3>(f);
}
template<class R, class T, class A1, class A2, class A3, class A4> _mfi::BOOST_MEM_FN_NAME(mf4)<R, T, A1, A2, A3, A4> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4))
{
return _mfi::BOOST_MEM_FN_NAME(mf4)<R, T, A1, A2, A3, A4>(f);
}
template<class R, class T, class A1, class A2, class A3, class A4> _mfi::BOOST_MEM_FN_NAME(cmf4)<R, T, A1, A2, A3, A4> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4) const)
{
return _mfi::BOOST_MEM_FN_NAME(cmf4)<R, T, A1, A2, A3, A4>(f);
}
template<class R, class T, class A1, class A2, class A3, class A4, class A5> _mfi::BOOST_MEM_FN_NAME(mf5)<R, T, A1, A2, A3, A4, A5> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5))
{
return _mfi::BOOST_MEM_FN_NAME(mf5)<R, T, A1, A2, A3, A4, A5>(f);
}
template<class R, class T, class A1, class A2, class A3, class A4, class A5> _mfi::BOOST_MEM_FN_NAME(cmf5)<R, T, A1, A2, A3, A4, A5> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5) const)
{
return _mfi::BOOST_MEM_FN_NAME(cmf5)<R, T, A1, A2, A3, A4, A5>(f);
}
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6> _mfi::BOOST_MEM_FN_NAME(mf6)<R, T, A1, A2, A3, A4, A5, A6> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5, A6))
{
return _mfi::BOOST_MEM_FN_NAME(mf6)<R, T, A1, A2, A3, A4, A5, A6>(f);
}
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6> _mfi::BOOST_MEM_FN_NAME(cmf6)<R, T, A1, A2, A3, A4, A5, A6> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5, A6) const)
{
return _mfi::BOOST_MEM_FN_NAME(cmf6)<R, T, A1, A2, A3, A4, A5, A6>(f);
}
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7> _mfi::BOOST_MEM_FN_NAME(mf7)<R, T, A1, A2, A3, A4, A5, A6, A7> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5, A6, A7))
{
return _mfi::BOOST_MEM_FN_NAME(mf7)<R, T, A1, A2, A3, A4, A5, A6, A7>(f);
}
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7> _mfi::BOOST_MEM_FN_NAME(cmf7)<R, T, A1, A2, A3, A4, A5, A6, A7> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5, A6, A7) const)
{
return _mfi::BOOST_MEM_FN_NAME(cmf7)<R, T, A1, A2, A3, A4, A5, A6, A7>(f);
}
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> _mfi::BOOST_MEM_FN_NAME(mf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5, A6, A7, A8))
{
return _mfi::BOOST_MEM_FN_NAME(mf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8>(f);
}
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> _mfi::BOOST_MEM_FN_NAME(cmf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8> mem_fn(R (BOOST_MEM_FN_CC T::*f) (A1, A2, A3, A4, A5, A6, A7, A8) const)
{
return _mfi::BOOST_MEM_FN_NAME(cmf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8>(f);
}

View File

@@ -0,0 +1,755 @@
//
// bind/mem_fn_template.hpp
//
// Do not include this header directly
//
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// See http://www.boost.org/libs/bind/mem_fn.html for documentation.
//
// mf0
template<class R, class T BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(mf0)
{
public:
typedef R result_type;
typedef T * argument_type;
private:
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) ())
F f_;
template<class U> R call(U & u, T const *) const
{
BOOST_MEM_FN_RETURN (u.*f_)();
}
template<class U> R call(U & u, void const *) const
{
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)();
}
public:
explicit BOOST_MEM_FN_NAME(mf0)(F f): f_(f) {}
R operator()(T * p) const
{
BOOST_MEM_FN_RETURN (p->*f_)();
}
template<class U> R operator()(U & u) const
{
BOOST_MEM_FN_RETURN call(u, &u);
}
R operator()(T & t) const
{
BOOST_MEM_FN_RETURN (t.*f_)();
}
};
// cmf0
template<class R, class T BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(cmf0)
{
public:
typedef R result_type;
typedef T const * argument_type;
private:
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) () const)
F f_;
template<class U> R call(U & u, T const *) const
{
BOOST_MEM_FN_RETURN (u.*f_)();
}
template<class U> R call(U & u, void const *) const
{
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)();
}
public:
explicit BOOST_MEM_FN_NAME(cmf0)(F f): f_(f) {}
template<class U> R operator()(U const & u) const
{
BOOST_MEM_FN_RETURN call(u, &u);
}
R operator()(T const & t) const
{
BOOST_MEM_FN_RETURN (t.*f_)();
}
};
// mf1
template<class R, class T, class A1 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(mf1)
{
public:
typedef R result_type;
typedef T * first_argument_type;
typedef A1 second_argument_type;
private:
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1))
F f_;
template<class U, class B1> R call(U & u, T const *, B1 & b1) const
{
BOOST_MEM_FN_RETURN (u.*f_)(b1);
}
template<class U, class B1> R call(U & u, void const *, B1 & b1) const
{
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1);
}
public:
explicit BOOST_MEM_FN_NAME(mf1)(F f): f_(f) {}
R operator()(T * p, A1 a1) const
{
BOOST_MEM_FN_RETURN (p->*f_)(a1);
}
template<class U> R operator()(U & u, A1 a1) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1);
}
R operator()(T & t, A1 a1) const
{
BOOST_MEM_FN_RETURN (t.*f_)(a1);
}
};
// cmf1
template<class R, class T, class A1 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(cmf1)
{
public:
typedef R result_type;
typedef T const * first_argument_type;
typedef A1 second_argument_type;
private:
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1) const)
F f_;
template<class U, class B1> R call(U & u, T const *, B1 & b1) const
{
BOOST_MEM_FN_RETURN (u.*f_)(b1);
}
template<class U, class B1> R call(U & u, void const *, B1 & b1) const
{
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1);
}
public:
explicit BOOST_MEM_FN_NAME(cmf1)(F f): f_(f) {}
template<class U> R operator()(U const & u, A1 a1) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1);
}
R operator()(T const & t, A1 a1) const
{
BOOST_MEM_FN_RETURN (t.*f_)(a1);
}
};
// mf2
template<class R, class T, class A1, class A2 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(mf2)
{
public:
typedef R result_type;
private:
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2))
F f_;
template<class U, class B1, class B2> R call(U & u, T const *, B1 & b1, B2 & b2) const
{
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2);
}
template<class U, class B1, class B2> R call(U & u, void const *, B1 & b1, B2 & b2) const
{
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2);
}
public:
explicit BOOST_MEM_FN_NAME(mf2)(F f): f_(f) {}
R operator()(T * p, A1 a1, A2 a2) const
{
BOOST_MEM_FN_RETURN (p->*f_)(a1, a2);
}
template<class U> R operator()(U & u, A1 a1, A2 a2) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2);
}
R operator()(T & t, A1 a1, A2 a2) const
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2);
}
};
// cmf2
template<class R, class T, class A1, class A2 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(cmf2)
{
public:
typedef R result_type;
private:
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2) const)
F f_;
template<class U, class B1, class B2> R call(U & u, T const *, B1 & b1, B2 & b2) const
{
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2);
}
template<class U, class B1, class B2> R call(U & u, void const *, B1 & b1, B2 & b2) const
{
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2);
}
public:
explicit BOOST_MEM_FN_NAME(cmf2)(F f): f_(f) {}
template<class U> R operator()(U const & u, A1 a1, A2 a2) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2);
}
R operator()(T const & t, A1 a1, A2 a2) const
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2);
}
};
// mf3
template<class R, class T, class A1, class A2, class A3 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(mf3)
{
public:
typedef R result_type;
private:
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3))
F f_;
template<class U, class B1, class B2, class B3> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3) const
{
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3);
}
template<class U, class B1, class B2, class B3> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3) const
{
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3);
}
public:
explicit BOOST_MEM_FN_NAME(mf3)(F f): f_(f) {}
R operator()(T * p, A1 a1, A2 a2, A3 a3) const
{
BOOST_MEM_FN_RETURN (p->*f_)(a1, a2, a3);
}
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3);
}
R operator()(T & t, A1 a1, A2 a2, A3 a3) const
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3);
}
};
// cmf3
template<class R, class T, class A1, class A2, class A3 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(cmf3)
{
public:
typedef R result_type;
private:
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3) const)
F f_;
template<class U, class B1, class B2, class B3> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3) const
{
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3);
}
template<class U, class B1, class B2, class B3> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3) const
{
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3);
}
public:
explicit BOOST_MEM_FN_NAME(cmf3)(F f): f_(f) {}
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3) const
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3);
}
};
// mf4
template<class R, class T, class A1, class A2, class A3, class A4 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(mf4)
{
public:
typedef R result_type;
private:
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4))
F f_;
template<class U, class B1, class B2, class B3, class B4> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4) const
{
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3, b4);
}
template<class U, class B1, class B2, class B3, class B4> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4) const
{
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3, b4);
}
public:
explicit BOOST_MEM_FN_NAME(mf4)(F f): f_(f) {}
R operator()(T * p, A1 a1, A2 a2, A3 a3, A4 a4) const
{
BOOST_MEM_FN_RETURN (p->*f_)(a1, a2, a3, a4);
}
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4);
}
R operator()(T & t, A1 a1, A2 a2, A3 a3, A4 a4) const
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4);
}
};
// cmf4
template<class R, class T, class A1, class A2, class A3, class A4 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(cmf4)
{
public:
typedef R result_type;
private:
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4) const)
F f_;
template<class U, class B1, class B2, class B3, class B4> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4) const
{
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3, b4);
}
template<class U, class B1, class B2, class B3, class B4> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4) const
{
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3, b4);
}
public:
explicit BOOST_MEM_FN_NAME(cmf4)(F f): f_(f) {}
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4) const
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4);
}
};
// mf5
template<class R, class T, class A1, class A2, class A3, class A4, class A5 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(mf5)
{
public:
typedef R result_type;
private:
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5))
F f_;
template<class U, class B1, class B2, class B3, class B4, class B5> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5) const
{
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3, b4, b5);
}
template<class U, class B1, class B2, class B3, class B4, class B5> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5) const
{
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3, b4, b5);
}
public:
explicit BOOST_MEM_FN_NAME(mf5)(F f): f_(f) {}
R operator()(T * p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
{
BOOST_MEM_FN_RETURN (p->*f_)(a1, a2, a3, a4, a5);
}
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5);
}
R operator()(T & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5);
}
};
// cmf5
template<class R, class T, class A1, class A2, class A3, class A4, class A5 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(cmf5)
{
public:
typedef R result_type;
private:
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5) const)
F f_;
template<class U, class B1, class B2, class B3, class B4, class B5> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5) const
{
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3, b4, b5);
}
template<class U, class B1, class B2, class B3, class B4, class B5> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5) const
{
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3, b4, b5);
}
public:
explicit BOOST_MEM_FN_NAME(cmf5)(F f): f_(f) {}
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5);
}
};
// mf6
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(mf6)
{
public:
typedef R result_type;
private:
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6))
F f_;
template<class U, class B1, class B2, class B3, class B4, class B5, class B6> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6) const
{
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3, b4, b5, b6);
}
template<class U, class B1, class B2, class B3, class B4, class B5, class B6> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6) const
{
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3, b4, b5, b6);
}
public:
explicit BOOST_MEM_FN_NAME(mf6)(F f): f_(f) {}
R operator()(T * p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
{
BOOST_MEM_FN_RETURN (p->*f_)(a1, a2, a3, a4, a5, a6);
}
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6);
}
R operator()(T & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6);
}
};
// cmf6
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(cmf6)
{
public:
typedef R result_type;
private:
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6) const)
F f_;
template<class U, class B1, class B2, class B3, class B4, class B5, class B6> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6) const
{
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3, b4, b5, b6);
}
template<class U, class B1, class B2, class B3, class B4, class B5, class B6> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6) const
{
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3, b4, b5, b6);
}
public:
explicit BOOST_MEM_FN_NAME(cmf6)(F f): f_(f) {}
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6);
}
};
// mf7
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(mf7)
{
public:
typedef R result_type;
private:
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6, A7))
F f_;
template<class U, class B1, class B2, class B3, class B4, class B5, class B6, class B7> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6, B7 & b7) const
{
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3, b4, b5, b6, b7);
}
template<class U, class B1, class B2, class B3, class B4, class B5, class B6, class B7> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6, B7 & b7) const
{
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3, b4, b5, b6, b7);
}
public:
explicit BOOST_MEM_FN_NAME(mf7)(F f): f_(f) {}
R operator()(T * p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
{
BOOST_MEM_FN_RETURN (p->*f_)(a1, a2, a3, a4, a5, a6, a7);
}
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7);
}
R operator()(T & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6, a7);
}
};
// cmf7
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(cmf7)
{
public:
typedef R result_type;
private:
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6, A7) const)
F f_;
template<class U, class B1, class B2, class B3, class B4, class B5, class B6, class B7> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6, B7 & b7) const
{
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3, b4, b5, b6, b7);
}
template<class U, class B1, class B2, class B3, class B4, class B5, class B6, class B7> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6, B7 & b7) const
{
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3, b4, b5, b6, b7);
}
public:
explicit BOOST_MEM_FN_NAME(cmf7)(F f): f_(f) {}
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6, a7);
}
};
// mf8
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(mf8)
{
public:
typedef R result_type;
private:
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6, A7, A8))
F f_;
template<class U, class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6, B7 & b7, B8 & b8) const
{
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3, b4, b5, b6, b7, b8);
}
template<class U, class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6, B7 & b7, B8 & b8) const
{
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3, b4, b5, b6, b7, b8);
}
public:
explicit BOOST_MEM_FN_NAME(mf8)(F f): f_(f) {}
R operator()(T * p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
{
BOOST_MEM_FN_RETURN (p->*f_)(a1, a2, a3, a4, a5, a6, a7, a8);
}
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7, a8);
}
R operator()(T & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6, a7, a8);
}
};
// cmf8
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(cmf8)
{
public:
typedef R result_type;
private:
BOOST_MEM_FN_TYPEDEF(R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6, A7, A8) const)
F f_;
template<class U, class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8> R call(U & u, T const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6, B7 & b7, B8 & b8) const
{
BOOST_MEM_FN_RETURN (u.*f_)(b1, b2, b3, b4, b5, b6, b7, b8);
}
template<class U, class B1, class B2, class B3, class B4, class B5, class B6, class B7, class B8> R call(U & u, void const *, B1 & b1, B2 & b2, B3 & b3, B4 & b4, B5 & b5, B6 & b6, B7 & b7, B8 & b8) const
{
BOOST_MEM_FN_RETURN (get_pointer(u)->*f_)(b1, b2, b3, b4, b5, b6, b7, b8);
}
public:
explicit BOOST_MEM_FN_NAME(cmf8)(F f): f_(f) {}
R operator()(T const * p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
{
BOOST_MEM_FN_RETURN (p->*f_)(a1, a2, a3, a4, a5, a6, a7, a8);
}
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7, a8);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
{
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6, a7, a8);
}
};

View File

@@ -0,0 +1,131 @@
//
// bind/mem_fn_vw.hpp - void return helper wrappers
//
// Do not include this header directly
//
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// See http://www.boost.org/libs/bind/mem_fn.html for documentation.
//
template<class R, class T> struct BOOST_MEM_FN_NAME(mf0): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf0)<R, T, R (BOOST_MEM_FN_CC T::*) ()>
{
typedef R (BOOST_MEM_FN_CC T::*F) ();
explicit BOOST_MEM_FN_NAME(mf0)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf0)<R, T, F>(f) {}
};
template<class R, class T> struct BOOST_MEM_FN_NAME(cmf0): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf0)<R, T, R (BOOST_MEM_FN_CC T::*) () const>
{
typedef R (BOOST_MEM_FN_CC T::*F) () const;
explicit BOOST_MEM_FN_NAME(cmf0)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf0)<R, T, F>(f) {}
};
template<class R, class T, class A1> struct BOOST_MEM_FN_NAME(mf1): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf1)<R, T, A1, R (BOOST_MEM_FN_CC T::*) (A1)>
{
typedef R (BOOST_MEM_FN_CC T::*F) (A1);
explicit BOOST_MEM_FN_NAME(mf1)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf1)<R, T, A1, F>(f) {}
};
template<class R, class T, class A1> struct BOOST_MEM_FN_NAME(cmf1): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf1)<R, T, A1, R (BOOST_MEM_FN_CC T::*) (A1) const>
{
typedef R (BOOST_MEM_FN_CC T::*F) (A1) const;
explicit BOOST_MEM_FN_NAME(cmf1)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf1)<R, T, A1, F>(f) {}
};
template<class R, class T, class A1, class A2> struct BOOST_MEM_FN_NAME(mf2): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf2)<R, T, A1, A2, R (BOOST_MEM_FN_CC T::*) (A1, A2)>
{
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2);
explicit BOOST_MEM_FN_NAME(mf2)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf2)<R, T, A1, A2, F>(f) {}
};
template<class R, class T, class A1, class A2> struct BOOST_MEM_FN_NAME(cmf2): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf2)<R, T, A1, A2, R (BOOST_MEM_FN_CC T::*) (A1, A2) const>
{
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2) const;
explicit BOOST_MEM_FN_NAME(cmf2)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf2)<R, T, A1, A2, F>(f) {}
};
template<class R, class T, class A1, class A2, class A3> struct BOOST_MEM_FN_NAME(mf3): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf3)<R, T, A1, A2, A3, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3)>
{
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3);
explicit BOOST_MEM_FN_NAME(mf3)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf3)<R, T, A1, A2, A3, F>(f) {}
};
template<class R, class T, class A1, class A2, class A3> struct BOOST_MEM_FN_NAME(cmf3): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf3)<R, T, A1, A2, A3, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3) const>
{
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3) const;
explicit BOOST_MEM_FN_NAME(cmf3)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf3)<R, T, A1, A2, A3, F>(f) {}
};
template<class R, class T, class A1, class A2, class A3, class A4> struct BOOST_MEM_FN_NAME(mf4): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf4)<R, T, A1, A2, A3, A4, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4)>
{
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4);
explicit BOOST_MEM_FN_NAME(mf4)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf4)<R, T, A1, A2, A3, A4, F>(f) {}
};
template<class R, class T, class A1, class A2, class A3, class A4> struct BOOST_MEM_FN_NAME(cmf4): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf4)<R, T, A1, A2, A3, A4, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4) const>
{
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4) const;
explicit BOOST_MEM_FN_NAME(cmf4)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf4)<R, T, A1, A2, A3, A4, F>(f) {}
};
template<class R, class T, class A1, class A2, class A3, class A4, class A5> struct BOOST_MEM_FN_NAME(mf5): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf5)<R, T, A1, A2, A3, A4, A5, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5)>
{
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5);
explicit BOOST_MEM_FN_NAME(mf5)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf5)<R, T, A1, A2, A3, A4, A5, F>(f) {}
};
template<class R, class T, class A1, class A2, class A3, class A4, class A5> struct BOOST_MEM_FN_NAME(cmf5): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf5)<R, T, A1, A2, A3, A4, A5, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5) const>
{
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5) const;
explicit BOOST_MEM_FN_NAME(cmf5)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf5)<R, T, A1, A2, A3, A4, A5, F>(f) {}
};
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6> struct BOOST_MEM_FN_NAME(mf6): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf6)<R, T, A1, A2, A3, A4, A5, A6, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5, A6)>
{
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6);
explicit BOOST_MEM_FN_NAME(mf6)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf6)<R, T, A1, A2, A3, A4, A5, A6, F>(f) {}
};
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6> struct BOOST_MEM_FN_NAME(cmf6): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf6)<R, T, A1, A2, A3, A4, A5, A6, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5, A6) const>
{
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6) const;
explicit BOOST_MEM_FN_NAME(cmf6)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf6)<R, T, A1, A2, A3, A4, A5, A6, F>(f) {}
};
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7> struct BOOST_MEM_FN_NAME(mf7): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf7)<R, T, A1, A2, A3, A4, A5, A6, A7, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5, A6, A7)>
{
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6, A7);
explicit BOOST_MEM_FN_NAME(mf7)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf7)<R, T, A1, A2, A3, A4, A5, A6, A7, F>(f) {}
};
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7> struct BOOST_MEM_FN_NAME(cmf7): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf7)<R, T, A1, A2, A3, A4, A5, A6, A7, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5, A6, A7) const>
{
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6, A7) const;
explicit BOOST_MEM_FN_NAME(cmf7)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf7)<R, T, A1, A2, A3, A4, A5, A6, A7, F>(f) {}
};
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> struct BOOST_MEM_FN_NAME(mf8): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5, A6, A7, A8)>
{
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6, A7, A8);
explicit BOOST_MEM_FN_NAME(mf8)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(mf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8, F>(f) {}
};
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> struct BOOST_MEM_FN_NAME(cmf8): public mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8, R (BOOST_MEM_FN_CC T::*) (A1, A2, A3, A4, A5, A6, A7, A8) const>
{
typedef R (BOOST_MEM_FN_CC T::*F) (A1, A2, A3, A4, A5, A6, A7, A8) const;
explicit BOOST_MEM_FN_NAME(cmf8)(F f): mf<R>::BOOST_NESTED_TEMPLATE BOOST_MEM_FN_NAME2(cmf8)<R, T, A1, A2, A3, A4, A5, A6, A7, A8, F>(f) {}
};

View File

@@ -0,0 +1,49 @@
#ifndef BOOST_BIND_PLACEHOLDERS_HPP_INCLUDED
#define BOOST_BIND_PLACEHOLDERS_HPP_INCLUDED
#if _MSC_VER >= 1020
#pragma once
#endif
//
// bind/placeholders.hpp - _N definitions
//
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
// See http://www.boost.org/libs/bind/bind.html for documentation.
//
#include <boost/bind/arg.hpp>
#include <boost/config.hpp>
// With MSVC precompiled headers, unnamed namespaces are not unique
#ifdef BOOST_MSVC
# define BOOST_BIND_STATIC static
#else
# define BOOST_BIND_STATIC
#endif
namespace
{
BOOST_BIND_STATIC boost::arg<1> _1;
BOOST_BIND_STATIC boost::arg<2> _2;
BOOST_BIND_STATIC boost::arg<3> _3;
BOOST_BIND_STATIC boost::arg<4> _4;
BOOST_BIND_STATIC boost::arg<5> _5;
BOOST_BIND_STATIC boost::arg<6> _6;
BOOST_BIND_STATIC boost::arg<7> _7;
BOOST_BIND_STATIC boost::arg<8> _8;
BOOST_BIND_STATIC boost::arg<9> _9;
} // unnamed namespace
#undef BOOST_BIND_STATIC
#endif // #ifndef BOOST_BIND_PLACEHOLDERS_HPP_INCLUDED

View File

@@ -1,16 +1,15 @@
#ifndef BOOST_MEM_FN_HPP_INCLUDED
#define BOOST_MEM_FN_HPP_INCLUDED
#if _MSC_VER >= 1020
#if _MSC_VER+0 >= 1020
#pragma once
#endif
//
// mem_fn.hpp - a generalization of std::mem_fun[_ref]
//
// Version 1.02.0001 (2001-08-30)
//
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
// Copyright (c) 2001 David Abrahams
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
@@ -20,6 +19,8 @@
// See http://www.boost.org/libs/bind/mem_fn.html for documentation.
//
#include <boost/config.hpp>
namespace boost
{
@@ -30,674 +31,161 @@ template<class T> T * get_pointer(T * p)
return p;
}
// implementation of get_pointer for boost::shared_ptr
// this will probably migrate to boost/shared_ptr.hpp
// get_pointer(shared_ptr<T> const & p) has been moved to shared_ptr.hpp
template<class T> class shared_ptr;
#if defined(BOOST_NO_VOID_RETURNS)
template<class T> T * get_pointer(shared_ptr<T> const & p)
{
return p.get();
}
//
#define BOOST_MEM_FN_CLASS_F , class F
#define BOOST_MEM_FN_TYPEDEF(X)
namespace _mfi // mem_fun_impl
{
// mf0
template<class R, class T> class mf0
template<class V> struct mf
{
public:
typedef R result_type;
typedef T * first_argument_type;
#define BOOST_MEM_FN_RETURN return
private:
typedef R (T::*F) ();
F f_;
#define BOOST_MEM_FN_NAME(X) inner_##X
#define BOOST_MEM_FN_CC
public:
explicit mf0(F f): f_(f) {}
#include <boost/bind/mem_fn_template.hpp>
R operator()(T * p) const
{
return (p->*f_)();
}
#undef BOOST_MEM_FN_CC
#undef BOOST_MEM_FN_NAME
template<class U> R operator()(U & u) const
{
return (get_pointer(u)->*f_)();
}
#ifdef BOOST_MEM_FN_ENABLE_STDCALL
R operator()(T & t) const
{
return (t.*f_)();
}
};
#define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall
#define BOOST_MEM_FN_CC __stdcall
// cmf0
#include <boost/bind/mem_fn_template.hpp>
template<class R, class T> class cmf0
#undef BOOST_MEM_FN_CC
#undef BOOST_MEM_FN_NAME
#endif
#undef BOOST_MEM_FN_RETURN
}; // struct mf<V>
template<> struct mf<void>
{
public:
typedef R result_type;
typedef T const * first_argument_type;
#define BOOST_MEM_FN_RETURN
private:
typedef R (T::*F) () const;
F f_;
#define BOOST_MEM_FN_NAME(X) inner_##X
#define BOOST_MEM_FN_CC
public:
explicit cmf0(F f): f_(f) {}
#include <boost/bind/mem_fn_template.hpp>
template<class U> R operator()(U const & u) const
{
return (get_pointer(u)->*f_)();
}
#undef BOOST_MEM_FN_CC
#undef BOOST_MEM_FN_NAME
R operator()(T const & t) const
{
return (t.*f_)();
}
};
#ifdef BOOST_MEM_FN_ENABLE_STDCALL
// mf1
#define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall
#define BOOST_MEM_FN_CC __stdcall
template<class R, class T, class A1> class mf1
{
public:
#include <boost/bind/mem_fn_template.hpp>
typedef R result_type;
typedef T * first_argument_type;
typedef A1 second_argument_type;
#undef BOOST_MEM_FN_CC
#undef BOOST_MEM_FN_NAME
private:
typedef R (T::*F) (A1);
F f_;
#endif
public:
explicit mf1(F f): f_(f) {}
#undef BOOST_MEM_FN_RETURN
R operator()(T * p, A1 a1) const
{
return (p->*f_)(a1);
}
}; // struct mf<void>
template<class U> R operator()(U & u, A1 a1) const
{
return (get_pointer(u)->*f_)(a1);
}
#undef BOOST_MEM_FN_CLASS_F
#undef BOOST_MEM_FN_TYPEDEF_F
R operator()(T & t, A1 a1) const
{
return (t.*f_)(a1);
}
};
#define BOOST_MEM_FN_NAME(X) X
#define BOOST_MEM_FN_NAME2(X) inner_##X
#define BOOST_MEM_FN_CC
// cmf1
#include <boost/bind/mem_fn_vw.hpp>
template<class R, class T, class A1> class cmf1
{
public:
#undef BOOST_MEM_FN_NAME
#undef BOOST_MEM_FN_NAME2
#undef BOOST_MEM_FN_CC
typedef R result_type;
typedef T const * first_argument_type;
typedef A1 second_argument_type;
#ifdef BOOST_MEM_FN_ENABLE_STDCALL
private:
typedef R (T::*F) (A1) const;
F f_;
#define BOOST_MEM_FN_NAME(X) X##_stdcall
#define BOOST_MEM_FN_NAME2(X) inner_##X##_stdcall
#define BOOST_MEM_FN_CC __stdcall
public:
explicit cmf1(F f): f_(f) {}
#include <boost/bind/mem_fn_vw.hpp>
template<class U> R operator()(U const & u, A1 a1) const
{
return (get_pointer(u)->*f_)(a1);
}
#undef BOOST_MEM_FN_NAME
#undef BOOST_MEM_FN_NAME2
#undef BOOST_MEM_FN_CC
R operator()(T const & t, A1 a1) const
{
return (t.*f_)(a1);
}
};
// mf2
template<class R, class T, class A1, class A2> class mf2
{
public:
typedef R result_type;
private:
typedef R (T::*F) (A1, A2);
F f_;
public:
explicit mf2(F f): f_(f) {}
R operator()(T * p, A1 a1, A2 a2) const
{
return (p->*f_)(a1, a2);
}
template<class U> R operator()(U & u, A1 a1, A2 a2) const
{
return (get_pointer(u)->*f_)(a1, a2);
}
R operator()(T & t, A1 a1, A2 a2) const
{
return (t.*f_)(a1, a2);
}
};
// cmf2
template<class R, class T, class A1, class A2> class cmf2
{
public:
typedef R result_type;
private:
typedef R (T::*F) (A1, A2) const;
F f_;
public:
explicit cmf2(F f): f_(f) {}
template<class U> R operator()(U const & u, A1 a1, A2 a2) const
{
return (get_pointer(u)->*f_)(a1, a2);
}
R operator()(T const & t, A1 a1, A2 a2) const
{
return (t.*f_)(a1, a2);
}
};
// mf3
template<class R, class T, class A1, class A2, class A3> class mf3
{
public:
typedef R result_type;
private:
typedef R (T::*F) (A1, A2, A3);
F f_;
public:
explicit mf3(F f): f_(f) {}
R operator()(T * p, A1 a1, A2 a2, A3 a3) const
{
return (p->*f_)(a1, a2, a3);
}
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3) const
{
return (get_pointer(u)->*f_)(a1, a2, a3);
}
R operator()(T & t, A1 a1, A2 a2, A3 a3) const
{
return (t.*f_)(a1, a2, a3);
}
};
// cmf3
template<class R, class T, class A1, class A2, class A3> class cmf3
{
public:
typedef R result_type;
private:
typedef R (T::*F) (A1, A2, A3) const;
F f_;
public:
explicit cmf3(F f): f_(f) {}
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3) const
{
return (get_pointer(u)->*f_)(a1, a2, a3);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3) const
{
return (t.*f_)(a1, a2, a3);
}
};
// mf4
template<class R, class T, class A1, class A2, class A3, class A4> class mf4
{
public:
typedef R result_type;
private:
typedef R (T::*F) (A1, A2, A3, A4);
F f_;
public:
explicit mf4(F f): f_(f) {}
R operator()(T * p, A1 a1, A2 a2, A3 a3, A4 a4) const
{
return (p->*f_)(a1, a2, a3, a4);
}
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4) const
{
return (get_pointer(u)->*f_)(a1, a2, a3, a4);
}
R operator()(T & t, A1 a1, A2 a2, A3 a3, A4 a4) const
{
return (t.*f_)(a1, a2, a3, a4);
}
};
// cmf4
template<class R, class T, class A1, class A2, class A3, class A4> class cmf4
{
public:
typedef R result_type;
private:
typedef R (T::*F) (A1, A2, A3, A4) const;
F f_;
public:
explicit cmf4(F f): f_(f) {}
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4) const
{
return (get_pointer(u)->*f_)(a1, a2, a3, a4);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4) const
{
return (t.*f_)(a1, a2, a3, a4);
}
};
// mf5
template<class R, class T, class A1, class A2, class A3, class A4, class A5> class mf5
{
public:
typedef R result_type;
private:
typedef R (T::*F) (A1, A2, A3, A4, A5);
F f_;
public:
explicit mf5(F f): f_(f) {}
R operator()(T * p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
{
return (p->*f_)(a1, a2, a3, a4, a5);
}
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
{
return (get_pointer(u)->*f_)(a1, a2, a3, a4, a5);
}
R operator()(T & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
{
return (t.*f_)(a1, a2, a3, a4, a5);
}
};
// cmf5
template<class R, class T, class A1, class A2, class A3, class A4, class A5> class cmf5
{
public:
typedef R result_type;
private:
typedef R (T::*F) (A1, A2, A3, A4, A5) const;
F f_;
public:
explicit cmf5(F f): f_(f) {}
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
{
return (get_pointer(u)->*f_)(a1, a2, a3, a4, a5);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
{
return (t.*f_)(a1, a2, a3, a4, a5);
}
};
// mf6
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6> class mf6
{
public:
typedef R result_type;
private:
typedef R (T::*F) (A1, A2, A3, A4, A5, A6);
F f_;
public:
explicit mf6(F f): f_(f) {}
R operator()(T * p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
{
return (p->*f_)(a1, a2, a3, a4, a5, a6);
}
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
{
return (get_pointer(u)->*f_)(a1, a2, a3, a4, a5, a6);
}
R operator()(T & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
{
return (t.*f_)(a1, a2, a3, a4, a5, a6);
}
};
// cmf6
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6> class cmf6
{
public:
typedef R result_type;
private:
typedef R (T::*F) (A1, A2, A3, A4, A5, A6) const;
F f_;
public:
explicit cmf6(F f): f_(f) {}
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
{
return (get_pointer(u)->*f_)(a1, a2, a3, a4, a5, a6);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
{
return (t.*f_)(a1, a2, a3, a4, a5, a6);
}
};
// mf7
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7> class mf7
{
public:
typedef R result_type;
private:
typedef R (T::*F) (A1, A2, A3, A4, A5, A6, A7);
F f_;
public:
explicit mf7(F f): f_(f) {}
R operator()(T * p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
{
return (p->*f_)(a1, a2, a3, a4, a5, a6, a7);
}
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
{
return (get_pointer(u)->*f_)(a1, a2, a3, a4, a5, a6, a7);
}
R operator()(T & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
{
return (t.*f_)(a1, a2, a3, a4, a5, a6, a7);
}
};
// cmf7
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7> class cmf7
{
public:
typedef R result_type;
private:
typedef R (T::*F) (A1, A2, A3, A4, A5, A6, A7) const;
F f_;
public:
explicit cmf7(F f): f_(f) {}
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
{
return (get_pointer(u)->*f_)(a1, a2, a3, a4, a5, a6, a7);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
{
return (t.*f_)(a1, a2, a3, a4, a5, a6, a7);
}
};
// mf8
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> class mf8
{
public:
typedef R result_type;
private:
typedef R (T::*F) (A1, A2, A3, A4, A5, A6, A7, A8);
F f_;
public:
explicit mf8(F f): f_(f) {}
R operator()(T * p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
{
return (p->*f_)(a1, a2, a3, a4, a5, a6, a7, a8);
}
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
{
return (get_pointer(u)->*f_)(a1, a2, a3, a4, a5, a6, a7, a8);
}
R operator()(T & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
{
return (t.*f_)(a1, a2, a3, a4, a5, a6, a7, a8);
}
};
// cmf8
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> class cmf8
{
public:
typedef R result_type;
private:
typedef R (T::*F) (A1, A2, A3, A4, A5, A6, A7, A8) const;
F f_;
public:
explicit cmf8(F f): f_(f) {}
R operator()(T const * p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
{
return (p->*f_)(a1, a2, a3, a4, a5, a6, a7, a8);
}
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
{
return (get_pointer(u)->*f_)(a1, a2, a3, a4, a5, a6, a7, a8);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
{
return (t.*f_)(a1, a2, a3, a4, a5, a6, a7, a8);
}
};
#endif
} // namespace _mfi
// mem_fn
#else // #ifdef BOOST_NO_VOID_RETURNS
template<class R, class T> _mfi::mf0<R, T> mem_fn(R (T::*f) ())
{
return _mfi::mf0<R, T>(f);
}
#define BOOST_MEM_FN_CLASS_F
#define BOOST_MEM_FN_TYPEDEF(X) typedef X;
template<class R, class T> _mfi::cmf0<R, T> mem_fn(R (T::*f) () const)
namespace _mfi
{
return _mfi::cmf0<R, T>(f);
}
template<class R, class T, class A1> _mfi::mf1<R, T, A1> mem_fn(R (T::*f) (A1))
{
return _mfi::mf1<R, T, A1>(f);
}
#define BOOST_MEM_FN_RETURN return
template<class R, class T, class A1> _mfi::cmf1<R, T, A1> mem_fn(R (T::*f) (A1) const)
{
return _mfi::cmf1<R, T, A1>(f);
}
#define BOOST_MEM_FN_NAME(X) X
#define BOOST_MEM_FN_CC
template<class R, class T, class A1, class A2> _mfi::mf2<R, T, A1, A2> mem_fn(R (T::*f) (A1, A2))
{
return _mfi::mf2<R, T, A1, A2>(f);
}
#include <boost/bind/mem_fn_template.hpp>
template<class R, class T, class A1, class A2> _mfi::cmf2<R, T, A1, A2> mem_fn(R (T::*f) (A1, A2) const)
{
return _mfi::cmf2<R, T, A1, A2>(f);
}
#undef BOOST_MEM_FN_CC
#undef BOOST_MEM_FN_NAME
template<class R, class T, class A1, class A2, class A3> _mfi::mf3<R, T, A1, A2, A3> mem_fn(R (T::*f) (A1, A2, A3))
{
return _mfi::mf3<R, T, A1, A2, A3>(f);
}
#ifdef BOOST_MEM_FN_ENABLE_STDCALL
template<class R, class T, class A1, class A2, class A3> _mfi::cmf3<R, T, A1, A2, A3> mem_fn(R (T::*f) (A1, A2, A3) const)
{
return _mfi::cmf3<R, T, A1, A2, A3>(f);
}
#define BOOST_MEM_FN_NAME(X) X##_stdcall
#define BOOST_MEM_FN_CC __stdcall
template<class R, class T, class A1, class A2, class A3, class A4> _mfi::mf4<R, T, A1, A2, A3, A4> mem_fn(R (T::*f) (A1, A2, A3, A4))
{
return _mfi::mf4<R, T, A1, A2, A3, A4>(f);
}
#include <boost/bind/mem_fn_template.hpp>
template<class R, class T, class A1, class A2, class A3, class A4> _mfi::cmf4<R, T, A1, A2, A3, A4> mem_fn(R (T::*f) (A1, A2, A3, A4) const)
{
return _mfi::cmf4<R, T, A1, A2, A3, A4>(f);
}
#undef BOOST_MEM_FN_CC
#undef BOOST_MEM_FN_NAME
template<class R, class T, class A1, class A2, class A3, class A4, class A5> _mfi::mf5<R, T, A1, A2, A3, A4, A5> mem_fn(R (T::*f) (A1, A2, A3, A4, A5))
{
return _mfi::mf5<R, T, A1, A2, A3, A4, A5>(f);
}
#endif
template<class R, class T, class A1, class A2, class A3, class A4, class A5> _mfi::cmf5<R, T, A1, A2, A3, A4, A5> mem_fn(R (T::*f) (A1, A2, A3, A4, A5) const)
{
return _mfi::cmf5<R, T, A1, A2, A3, A4, A5>(f);
}
#undef BOOST_MEM_FN_RETURN
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6> _mfi::mf6<R, T, A1, A2, A3, A4, A5, A6> mem_fn(R (T::*f) (A1, A2, A3, A4, A5, A6))
{
return _mfi::mf6<R, T, A1, A2, A3, A4, A5, A6>(f);
}
} // namespace _mfi
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6> _mfi::cmf6<R, T, A1, A2, A3, A4, A5, A6> mem_fn(R (T::*f) (A1, A2, A3, A4, A5, A6) const)
{
return _mfi::cmf6<R, T, A1, A2, A3, A4, A5, A6>(f);
}
#undef BOOST_MEM_FN_CLASS_F
#undef BOOST_MEM_FN_TYPEDEF
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7> _mfi::mf7<R, T, A1, A2, A3, A4, A5, A6, A7> mem_fn(R (T::*f) (A1, A2, A3, A4, A5, A6, A7))
{
return _mfi::mf7<R, T, A1, A2, A3, A4, A5, A6, A7>(f);
}
#endif // #ifdef BOOST_NO_VOID_RETURNS
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7> _mfi::cmf7<R, T, A1, A2, A3, A4, A5, A6, A7> mem_fn(R (T::*f) (A1, A2, A3, A4, A5, A6, A7) const)
{
return _mfi::cmf7<R, T, A1, A2, A3, A4, A5, A6, A7>(f);
}
#define BOOST_MEM_FN_NAME(X) X
#define BOOST_MEM_FN_CC
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> _mfi::mf8<R, T, A1, A2, A3, A4, A5, A6, A7, A8> mem_fn(R (T::*f) (A1, A2, A3, A4, A5, A6, A7, A8))
{
return _mfi::mf8<R, T, A1, A2, A3, A4, A5, A6, A7, A8>(f);
}
#include <boost/bind/mem_fn_cc.hpp>
template<class R, class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> _mfi::cmf8<R, T, A1, A2, A3, A4, A5, A6, A7, A8> mem_fn(R (T::*f) (A1, A2, A3, A4, A5, A6, A7, A8) const)
{
return _mfi::cmf8<R, T, A1, A2, A3, A4, A5, A6, A7, A8>(f);
}
#undef BOOST_MEM_FN_NAME
#undef BOOST_MEM_FN_CC
#ifdef BOOST_MEM_FN_ENABLE_STDCALL
#define BOOST_MEM_FN_NAME(X) X##_stdcall
#define BOOST_MEM_FN_CC __stdcall
#include <boost/bind/mem_fn_cc.hpp>
#undef BOOST_MEM_FN_NAME
#undef BOOST_MEM_FN_CC
#endif
} // namespace boost

View File

@@ -7,18 +7,15 @@
<title>Boost: mem_fn.hpp documentation</title>
</head>
<body bgcolor="White">
<body bgcolor="White" style="margin-left: 5%; margin-right: 5%;">
<table border="0" width="100%">
<tr>
<td width="277">
<img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" WIDTH="277" HEIGHT="86">
<img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" width="277" height="86">
</td>
<td align="center">
<table border="0">
<tr><td nowrap><h1>mem_fn.hpp</h1></td></tr>
<tr><td align="right" nowrap><small>&nbsp;1.02.0001 (2001-08-30)</small></td></tr>
</table>
<h1>mem_fn.hpp</h1>
</td>
</tr>
<tr>
@@ -26,13 +23,29 @@
</tr>
</table>
<h2>Files</h2>
<ul>
<li><a href="../../boost/mem_fn.hpp">mem_fn.hpp</a> (implementation)
<li><a href="mem_fn_test.cpp">mem_fn_test.cpp</a> (test)
</ul>
<h2>Contents</h2>
<h2>Purpose</h2>
<h3 style="margin-left: 20pt;"><a href="#Purpose">Purpose</a></h3>
<h3 style="margin-left: 20pt;"><a href="#FAQ">Frequently Asked Questions</a></h3>
<h4 style="margin-left: 40pt;"><a href="#Q1">Can <b>mem_fn</b> be used instead of the standard
<b>std::mem_fun[_ref]</b> adaptors?</a></h4>
<h4 style="margin-left: 40pt;"><a href="#Q2">Should I replace every occurence of <b>std::mem_fun[_ref]</b>
with <b>mem_fn</b> in my existing code?</a></h4>
<h4 style="margin-left: 40pt;"><a href="#Q3">Does <b>mem_fn</b> work with COM methods?</a></h4>
<h4 style="margin-left: 40pt;"><a href="#Q4">Why isn't BOOST_MEM_FN_ENABLE_STDCALL defined automatically?</a></h4>
<h3 style="margin-left: 20pt;"><a href="#Interface">Interface</a></h3>
<h4 style="margin-left: 40pt;"><a href="#Synopsis">Synopsis</a></h4>
<h4 style="margin-left: 40pt;"><a href="#CommonRequirements">Common requirements</a></h4>
<h4 style="margin-left: 40pt;"><a href="#get_pointer">get_pointer</a></h4>
<h4 style="margin-left: 40pt;"><a href="#mem_fn">mem_fn</a></h4>
<h3 style="margin-left: 20pt;"><a href="#Implementation">Implementation</a></h3>
<h4 style="margin-left: 40pt;"><a href="#Files">Files</a></h4>
<h4 style="margin-left: 40pt;"><a href="#Dependencies">Dependencies</a></h4>
<h4 style="margin-left: 40pt;"><a href="#NumberOfArguments">Number of Arguments</a></h4>
<h4 style="margin-left: 40pt;"><a href="#stdcall">&quot;__stdcall&quot; Support</a></h4>
<h3 style="margin-left: 20pt;"><a href="#Acknowledgements">Acknowledgements</a></h3>
<h2><a name="Purpose">Purpose</a></h2>
<p>
<b>boost::mem_fn</b> is a generalization of the standard functions
@@ -42,6 +55,55 @@ object can take a pointer, a reference, or a smart pointer to an object
instance as its first argument.
</p>
<p>
The purpose of <b>mem_fn</b> is twofold. First, it allows users to invoke a
member function on a container with the familiar
</p>
<pre>
std::for_each(v.begin(), v.end(), boost::mem_fn(&amp;Shape::draw));
</pre>
<p>
syntax, even when the container stores smart pointers.
</p>
<p>
Second, it can be used as a building block by library developers that want
to treat a pointer to member function as a function object. A library might
define an enhanced <b>for_each</b> algorithm with an overload of the form:
</p>
<pre>
template&lt;class It, class R, class T&gt; void for_each(It first, It last, R (T::*pmf) ())
{
std::for_each(first, last, boost::mem_fn(pmf));
}
</pre>
<p>
that will allow the convenient syntax:
</p>
<pre>
for_each(v.begin(), v.end(), &amp;Shape::draw);
</pre>
<p>
When documenting the feature, the library author will simply state:
</p>
<h4 style="margin-left: 20pt;">template&lt;class It, class R, class T&gt; void for_each(It first, It last, R (T::*pmf) ());</h4>
<p style="margin-left: 20pt;">
<b>Effects:</b> equivalent to std::for_each(first, last, boost::mem_fn(pmf));
</p>
<p>
where <b>boost::mem_fn</b> can be a link to this page. See
<a href="bind.html">the documentation of <b>bind</b></a> for an example.
</p>
<p>
<b>mem_fn</b> takes one argument, a pointer to a member function, and
returns a function object suitable for use with standard or user-defined
@@ -106,9 +168,52 @@ All function objects returned by <b>mem_fn</b> expose a <b>result_type</b>
typedef that represents the return type of the member function.
</p>
<h2>Interface</h2>
<h2><a name="FAQ">Frequently Asked Questions</a></h2>
<h3>Synopsis</h3>
<h3><a name="Q1">Can <b>mem_fn</b> be used instead of the standard
<b>std::mem_fun[_ref]</b> adaptors?</a></h3>
<p>
Yes. For simple uses, <b>mem_fn</b> provides additional functionality that
the standard adaptors do not. Complicated expressions that use <b>std::bind1st</b>,
<b>std::bind2nd</b> or <a href="../compose/index.htm"><b>Boost.Compose</b></a>
along with the standard adaptors can be rewritten using
<a href="bind.html"><b>boost::bind</b></a> that automatically takes advantage of
<b>mem_fn</b>.
</p>
<h3><a name="Q2">Should I replace every occurence of <b>std::mem_fun[_ref]</b>
with <b>mem_fn</b> in my existing code?</a></h3>
<p>
No, unless you have good reasons to do so. <b>mem_fn</b> is not 100% compatible
with the standard adaptors, although it comes pretty close. In particular,
<b>mem_fn</b> does not return objects of type
<b>std::[const_]mem_fun[1][_ref]_t</b>, as the standard adaptors do, and it is
not possible to fully describe the type of the first argument using the standard
<b>argument_type</b> and <b>first_argument_type</b> nested typedefs. Libraries
that need adaptable function objects in order to function might not like
<b>mem_fn</b>.
</p>
<h3><a name="Q3">Does <b>mem_fn</b> work with COM methods?</a></h3>
<p>
Yes, if you <a href="#stdcall">#define BOOST_MEM_FN_ENABLE_STDCALL</a>.
</p>
<h3><a name="Q4">Why isn't BOOST_MEM_FN_ENABLE_STDCALL defined automatically?</a></h3>
<p>
Non-portable extensions, in general, should default to off to prevent vendor
lock-in. Had BOOST_MEM_FN_ENABLE_STDCALL been defined automatically, you could
have accidentally taken advantage of it without realizing that your code is,
perhaps, no longer portable.
</p>
<h2><a name="Interface">Interface</a></h2>
<h3><a name="Synopsis">Synopsis</a></h3>
<pre>
namespace boost
@@ -135,7 +240,7 @@ template&lt;class R, class T, class A1, class A2&gt; <i>implementation-defined-6
}
</pre>
<h3>Common requirements</h3>
<h3><a name="CommonRequirements">Common requirements</a></h3>
<p>
All <tt><i>implementation-defined-N</i></tt> types mentioned in the Synopsis are
@@ -146,7 +251,7 @@ the return type of the member function pointer passed as an argument to <b>mem_f
(<b>R</b> in the Synopsis.)
</p>
<h3>get_pointer</h3>
<h3><a name="get_pointer">get_pointer</a></h3>
<h4><a name="get_pointer_1">template&lt;class T&gt; T * get_pointer(T * p)</a></h4>
@@ -166,7 +271,7 @@ the return type of the member function pointer passed as an argument to <b>mem_f
<b>Throws:</b> Nothing.
</p>
<h3>mem_fn</h3>
<h3><a name="mem_fn">mem_fn</a></h3>
<h4><a name="mem_fn_1">template&lt;class R, class T&gt; <i>implementation-defined-1</i> mem_fn(R (T::*pmf) ())</a></h4>
@@ -234,7 +339,25 @@ is of type <b>T <i>[</i>const<i>]</i></b>, <tt>(get_pointer(t)->*pmf)(a1, a2)</t
<b>Throws:</b> Nothing.
</p>
<h2>Implementation</h2>
<h2><a name="Implementation">Implementation</a></h2>
<h3><a name="Files">Files</a></h3>
<ul>
<li><a href="../../boost/mem_fn.hpp">boost/mem_fn.hpp</a> (main header)
<li><a href="../../boost/bind/mem_fn_cc.hpp">boost/bind/mem_fn_cc.hpp</a> (used by mem_fn.hpp, do not include directly)
<li><a href="../../boost/bind/mem_fn_vw.hpp">boost/bind/mem_fn_vw.hpp</a> (used by mem_fn.hpp, do not include directly)
<li><a href="../../boost/bind/mem_fn_template.hpp">boost/bind/mem_fn_template.hpp</a> (used by mem_fn.hpp, do not include directly)
<li><a href="mem_fn_test.cpp">libs/bind/mem_fn_test.cpp</a> (test)
<li><a href="mem_fn_stdcall_test.cpp">libs/bind/mem_fn_stdcall_test.cpp</a> (test for __stdcall)
<li><a href="mem_fn_void_test.cpp">libs/bind/mem_fn_void_test.cpp</a> (test for void returns)
</ul>
<h3><a name="Dependencies">Dependencies</a></h3>
<ul>
<li><a href="../config/config.htm">Boost.Config</a>
</ul>
<h3><a name="NumberOfArguments">Number of Arguments</a></h3>
<p>
This implementation supports member functions with up to eight arguments.
@@ -242,7 +365,36 @@ This is not an inherent limitation of the design, but an implementation
detail.
</p>
<h2>Acknowledgements</h2>
<h3><a name="stdcall">&quot;__stdcall&quot; Support</a></h3>
<p>
Some platforms allow several types of member functions that differ by their
<b>calling convention</b> (the rules by which the function is invoked: how
are arguments passed, how is the return value handled, and who cleans up the
stack - if any.)
</p>
<p>
For example, Windows API functions and COM interface member functions use a
calling convention known as <b>__stdcall</b>.
</p>
<p>
To use <b>mem_fn</b> with <b>__stdcall</b> member functions, <b>#define</b>
the macro <b>BOOST_MEM_FN_ENABLE_STDCALL</b> before including, directly or
indirectly, <b>&lt;boost/mem_fn.hpp&gt;</b>.
</p>
<p>
[Note: this is a non-portable extension. It is not part of the interface.]
</p>
<p>
[Note: Some compilers provide only minimal support for the <b>__stdcall</b> keyword.]
</p>
<h2><a name="Acknowledgements">Acknowledgements</a></h2>
<p>
Rene Jager's initial suggestion of using traits classes to make
@@ -256,6 +408,14 @@ Richard Crossley, Jens Maurer, Ed Brey, and others. Review manager
was Darin Adler.
</p>
<p>
Steve Anichini pointed out that COM interfaces use <b>__stdcall</b>.
</p>
<p>
Dave Abrahams modified <b>bind</b> and <b>mem_fn</b> to support void returns
on deficient compilers.
</p>
<p><br><br><br><small>Copyright &copy; 2001 by Peter Dimov and Multi Media
Ltd. Permission to copy, use, modify, sell and distribute this document is

187
mem_fn_derived_test.cpp Normal file
View File

@@ -0,0 +1,187 @@
#if defined(_MSC_VER) && !defined(__ICL)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion
#pragma warning(disable: 4514) // unreferenced inline removed
#endif
//
// mem_fn_derived_test.cpp - tests mem_fn.hpp with derived objects
//
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
#include <boost/mem_fn.hpp>
#include <boost/shared_ptr.hpp>
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(push, 3)
#endif
#include <iostream>
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(pop)
#endif
struct B
{
mutable unsigned int hash;
B(): hash(0) {}
int f0() { f1(17); return 0; }
int g0() const { g1(17); return 0; }
int f1(int a1) { hash = (hash * 17041 + a1) % 32768; return 0; }
int g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; }
int f2(int a1, int a2) { f1(a1); f1(a2); return 0; }
int g2(int a1, int a2) const { g1(a1); g1(a2); return 0; }
int f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; }
int g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; }
int f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; }
int g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; }
int f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; }
int g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; }
int f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; }
int g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; }
int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; }
int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; }
int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; }
int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; }
};
struct X: public B
{
};
int detect_errors(bool x)
{
if(x)
{
std::cerr << "no errors detected.\n";
return 0;
}
else
{
std::cerr << "test failed.\n";
return 1;
}
}
int main()
{
using boost::mem_fn;
X x;
X const & rcx = x;
X const * pcx = &x;
boost::shared_ptr<X> sp(new X);
mem_fn(&X::f0)(x);
mem_fn(&X::f0)(&x);
mem_fn(&X::f0)(sp);
mem_fn(&X::g0)(x);
mem_fn(&X::g0)(rcx);
mem_fn(&X::g0)(&x);
mem_fn(&X::g0)(pcx);
mem_fn(&X::g0)(sp);
mem_fn(&X::f1)(x, 1);
mem_fn(&X::f1)(&x, 1);
mem_fn(&X::f1)(sp, 1);
mem_fn(&X::g1)(x, 1);
mem_fn(&X::g1)(rcx, 1);
mem_fn(&X::g1)(&x, 1);
mem_fn(&X::g1)(pcx, 1);
mem_fn(&X::g1)(sp, 1);
mem_fn(&X::f2)(x, 1, 2);
mem_fn(&X::f2)(&x, 1, 2);
mem_fn(&X::f2)(sp, 1, 2);
mem_fn(&X::g2)(x, 1, 2);
mem_fn(&X::g2)(rcx, 1, 2);
mem_fn(&X::g2)(&x, 1, 2);
mem_fn(&X::g2)(pcx, 1, 2);
mem_fn(&X::g2)(sp, 1, 2);
mem_fn(&X::f3)(x, 1, 2, 3);
mem_fn(&X::f3)(&x, 1, 2, 3);
mem_fn(&X::f3)(sp, 1, 2, 3);
mem_fn(&X::g3)(x, 1, 2, 3);
mem_fn(&X::g3)(rcx, 1, 2, 3);
mem_fn(&X::g3)(&x, 1, 2, 3);
mem_fn(&X::g3)(pcx, 1, 2, 3);
mem_fn(&X::g3)(sp, 1, 2, 3);
mem_fn(&X::f4)(x, 1, 2, 3, 4);
mem_fn(&X::f4)(&x, 1, 2, 3, 4);
mem_fn(&X::f4)(sp, 1, 2, 3, 4);
mem_fn(&X::g4)(x, 1, 2, 3, 4);
mem_fn(&X::g4)(rcx, 1, 2, 3, 4);
mem_fn(&X::g4)(&x, 1, 2, 3, 4);
mem_fn(&X::g4)(pcx, 1, 2, 3, 4);
mem_fn(&X::g4)(sp, 1, 2, 3, 4);
mem_fn(&X::f5)(x, 1, 2, 3, 4, 5);
mem_fn(&X::f5)(&x, 1, 2, 3, 4, 5);
mem_fn(&X::f5)(sp, 1, 2, 3, 4, 5);
mem_fn(&X::g5)(x, 1, 2, 3, 4, 5);
mem_fn(&X::g5)(rcx, 1, 2, 3, 4, 5);
mem_fn(&X::g5)(&x, 1, 2, 3, 4, 5);
mem_fn(&X::g5)(pcx, 1, 2, 3, 4, 5);
mem_fn(&X::g5)(sp, 1, 2, 3, 4, 5);
mem_fn(&X::f6)(x, 1, 2, 3, 4, 5, 6);
mem_fn(&X::f6)(&x, 1, 2, 3, 4, 5, 6);
mem_fn(&X::f6)(sp, 1, 2, 3, 4, 5, 6);
mem_fn(&X::g6)(x, 1, 2, 3, 4, 5, 6);
mem_fn(&X::g6)(rcx, 1, 2, 3, 4, 5, 6);
mem_fn(&X::g6)(&x, 1, 2, 3, 4, 5, 6);
mem_fn(&X::g6)(pcx, 1, 2, 3, 4, 5, 6);
mem_fn(&X::g6)(sp, 1, 2, 3, 4, 5, 6);
mem_fn(&X::f7)(x, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::f7)(&x, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::f7)(sp, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::g7)(x, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::g7)(rcx, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::g7)(&x, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::g7)(pcx, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::g7)(sp, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::f8)(x, 1, 2, 3, 4, 5, 6, 7, 8);
mem_fn(&X::f8)(&x, 1, 2, 3, 4, 5, 6, 7, 8);
mem_fn(&X::f8)(sp, 1, 2, 3, 4, 5, 6, 7, 8);
mem_fn(&X::g8)(x, 1, 2, 3, 4, 5, 6, 7, 8);
mem_fn(&X::g8)(rcx, 1, 2, 3, 4, 5, 6, 7, 8);
mem_fn(&X::g8)(&x, 1, 2, 3, 4, 5, 6, 7, 8);
mem_fn(&X::g8)(pcx, 1, 2, 3, 4, 5, 6, 7, 8);
mem_fn(&X::g8)(sp, 1, 2, 3, 4, 5, 6, 7, 8);
return detect_errors(x.hash == 17610 && sp->hash == 2155);
}

185
mem_fn_stdcall_test.cpp Normal file
View File

@@ -0,0 +1,185 @@
#if defined(_MSC_VER) && !defined(__ICL)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion
#pragma warning(disable: 4514) // unreferenced inline removed
#endif
//
// mem_fn_stdcall_test.cpp - a test for mem_fn.hpp + __stdcall
//
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
#define BOOST_MEM_FN_ENABLE_STDCALL
#include <boost/mem_fn.hpp>
#include <boost/shared_ptr.hpp>
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(push, 3)
#endif
#include <iostream>
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(pop)
#endif
struct X
{
mutable unsigned int hash;
X(): hash(0) {}
int __stdcall f0() { f1(17); return 0; }
int __stdcall g0() const { g1(17); return 0; }
int __stdcall f1(int a1) { hash = (hash * 17041 + a1) % 32768; return 0; }
int __stdcall g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; }
int __stdcall f2(int a1, int a2) { f1(a1); f1(a2); return 0; }
int __stdcall g2(int a1, int a2) const { g1(a1); g1(a2); return 0; }
int __stdcall f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; }
int __stdcall g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; }
int __stdcall f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; }
int __stdcall g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; }
int __stdcall f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; }
int __stdcall g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; }
int __stdcall f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; }
int __stdcall g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; }
int __stdcall f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; }
int __stdcall g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; }
int __stdcall f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; }
int __stdcall g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; }
};
int detect_errors(bool x)
{
if(x)
{
std::cerr << "no errors detected.\n";
return 0;
}
else
{
std::cerr << "test failed.\n";
return 1;
}
}
int main()
{
using boost::mem_fn;
X x;
X const & rcx = x;
X const * pcx = &x;
boost::shared_ptr<X> sp(new X);
mem_fn(&X::f0)(x);
mem_fn(&X::f0)(&x);
mem_fn(&X::f0)(sp);
mem_fn(&X::g0)(x);
mem_fn(&X::g0)(rcx);
mem_fn(&X::g0)(&x);
mem_fn(&X::g0)(pcx);
mem_fn(&X::g0)(sp);
mem_fn(&X::f1)(x, 1);
mem_fn(&X::f1)(&x, 1);
mem_fn(&X::f1)(sp, 1);
mem_fn(&X::g1)(x, 1);
mem_fn(&X::g1)(rcx, 1);
mem_fn(&X::g1)(&x, 1);
mem_fn(&X::g1)(pcx, 1);
mem_fn(&X::g1)(sp, 1);
mem_fn(&X::f2)(x, 1, 2);
mem_fn(&X::f2)(&x, 1, 2);
mem_fn(&X::f2)(sp, 1, 2);
mem_fn(&X::g2)(x, 1, 2);
mem_fn(&X::g2)(rcx, 1, 2);
mem_fn(&X::g2)(&x, 1, 2);
mem_fn(&X::g2)(pcx, 1, 2);
mem_fn(&X::g2)(sp, 1, 2);
mem_fn(&X::f3)(x, 1, 2, 3);
mem_fn(&X::f3)(&x, 1, 2, 3);
mem_fn(&X::f3)(sp, 1, 2, 3);
mem_fn(&X::g3)(x, 1, 2, 3);
mem_fn(&X::g3)(rcx, 1, 2, 3);
mem_fn(&X::g3)(&x, 1, 2, 3);
mem_fn(&X::g3)(pcx, 1, 2, 3);
mem_fn(&X::g3)(sp, 1, 2, 3);
mem_fn(&X::f4)(x, 1, 2, 3, 4);
mem_fn(&X::f4)(&x, 1, 2, 3, 4);
mem_fn(&X::f4)(sp, 1, 2, 3, 4);
mem_fn(&X::g4)(x, 1, 2, 3, 4);
mem_fn(&X::g4)(rcx, 1, 2, 3, 4);
mem_fn(&X::g4)(&x, 1, 2, 3, 4);
mem_fn(&X::g4)(pcx, 1, 2, 3, 4);
mem_fn(&X::g4)(sp, 1, 2, 3, 4);
mem_fn(&X::f5)(x, 1, 2, 3, 4, 5);
mem_fn(&X::f5)(&x, 1, 2, 3, 4, 5);
mem_fn(&X::f5)(sp, 1, 2, 3, 4, 5);
mem_fn(&X::g5)(x, 1, 2, 3, 4, 5);
mem_fn(&X::g5)(rcx, 1, 2, 3, 4, 5);
mem_fn(&X::g5)(&x, 1, 2, 3, 4, 5);
mem_fn(&X::g5)(pcx, 1, 2, 3, 4, 5);
mem_fn(&X::g5)(sp, 1, 2, 3, 4, 5);
mem_fn(&X::f6)(x, 1, 2, 3, 4, 5, 6);
mem_fn(&X::f6)(&x, 1, 2, 3, 4, 5, 6);
mem_fn(&X::f6)(sp, 1, 2, 3, 4, 5, 6);
mem_fn(&X::g6)(x, 1, 2, 3, 4, 5, 6);
mem_fn(&X::g6)(rcx, 1, 2, 3, 4, 5, 6);
mem_fn(&X::g6)(&x, 1, 2, 3, 4, 5, 6);
mem_fn(&X::g6)(pcx, 1, 2, 3, 4, 5, 6);
mem_fn(&X::g6)(sp, 1, 2, 3, 4, 5, 6);
mem_fn(&X::f7)(x, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::f7)(&x, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::f7)(sp, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::g7)(x, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::g7)(rcx, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::g7)(&x, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::g7)(pcx, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::g7)(sp, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::f8)(x, 1, 2, 3, 4, 5, 6, 7, 8);
mem_fn(&X::f8)(&x, 1, 2, 3, 4, 5, 6, 7, 8);
mem_fn(&X::f8)(sp, 1, 2, 3, 4, 5, 6, 7, 8);
mem_fn(&X::g8)(x, 1, 2, 3, 4, 5, 6, 7, 8);
mem_fn(&X::g8)(rcx, 1, 2, 3, 4, 5, 6, 7, 8);
mem_fn(&X::g8)(&x, 1, 2, 3, 4, 5, 6, 7, 8);
mem_fn(&X::g8)(pcx, 1, 2, 3, 4, 5, 6, 7, 8);
mem_fn(&X::g8)(sp, 1, 2, 3, 4, 5, 6, 7, 8);
return detect_errors(x.hash == 17610 && sp->hash == 2155);
}

View File

@@ -8,8 +8,6 @@
//
// mem_fn_test.cpp - a test for mem_fn.hpp
//
// Version 1.02.0001 (2001-08-30)
//
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
//
// Permission to copy, use, modify, sell and distribute this software
@@ -19,9 +17,19 @@
//
#include <boost/mem_fn.hpp>
#include <boost/smart_ptr.hpp>
#include <boost/shared_ptr.hpp>
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(push, 3)
#endif
#include <iostream>
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(pop)
#endif
struct X
{
mutable unsigned int hash;

183
mem_fn_void_test.cpp Normal file
View File

@@ -0,0 +1,183 @@
#if defined(_MSC_VER) && !defined(__ICL)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion
#pragma warning(disable: 4514) // unreferenced inline removed
#endif
//
// mem_fn_void_test.cpp - a test for mem_fn.hpp + void returns
//
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
#include <boost/mem_fn.hpp>
#include <boost/shared_ptr.hpp>
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(push, 3)
#endif
#include <iostream>
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(pop)
#endif
struct X
{
mutable unsigned int hash;
X(): hash(0) {}
void f0() { f1(17); }
void g0() const { g1(17); }
void f1(int a1) { hash = (hash * 17041 + a1) % 32768; }
void g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; }
void f2(int a1, int a2) { f1(a1); f1(a2); }
void g2(int a1, int a2) const { g1(a1); g1(a2); }
void f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); }
void g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); }
void f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); }
void g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); }
void f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); }
void g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); }
void f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); }
void g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); }
void f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); }
void g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); }
void f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); }
void g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); }
};
int detect_errors(bool x)
{
if(x)
{
std::cerr << "no errors detected.\n";
return 0;
}
else
{
std::cerr << "test failed.\n";
return 1;
}
}
int main()
{
using boost::mem_fn;
X x;
X const & rcx = x;
X const * pcx = &x;
boost::shared_ptr<X> sp(new X);
mem_fn(&X::f0)(x);
mem_fn(&X::f0)(&x);
mem_fn(&X::f0)(sp);
mem_fn(&X::g0)(x);
mem_fn(&X::g0)(rcx);
mem_fn(&X::g0)(&x);
mem_fn(&X::g0)(pcx);
mem_fn(&X::g0)(sp);
mem_fn(&X::f1)(x, 1);
mem_fn(&X::f1)(&x, 1);
mem_fn(&X::f1)(sp, 1);
mem_fn(&X::g1)(x, 1);
mem_fn(&X::g1)(rcx, 1);
mem_fn(&X::g1)(&x, 1);
mem_fn(&X::g1)(pcx, 1);
mem_fn(&X::g1)(sp, 1);
mem_fn(&X::f2)(x, 1, 2);
mem_fn(&X::f2)(&x, 1, 2);
mem_fn(&X::f2)(sp, 1, 2);
mem_fn(&X::g2)(x, 1, 2);
mem_fn(&X::g2)(rcx, 1, 2);
mem_fn(&X::g2)(&x, 1, 2);
mem_fn(&X::g2)(pcx, 1, 2);
mem_fn(&X::g2)(sp, 1, 2);
mem_fn(&X::f3)(x, 1, 2, 3);
mem_fn(&X::f3)(&x, 1, 2, 3);
mem_fn(&X::f3)(sp, 1, 2, 3);
mem_fn(&X::g3)(x, 1, 2, 3);
mem_fn(&X::g3)(rcx, 1, 2, 3);
mem_fn(&X::g3)(&x, 1, 2, 3);
mem_fn(&X::g3)(pcx, 1, 2, 3);
mem_fn(&X::g3)(sp, 1, 2, 3);
mem_fn(&X::f4)(x, 1, 2, 3, 4);
mem_fn(&X::f4)(&x, 1, 2, 3, 4);
mem_fn(&X::f4)(sp, 1, 2, 3, 4);
mem_fn(&X::g4)(x, 1, 2, 3, 4);
mem_fn(&X::g4)(rcx, 1, 2, 3, 4);
mem_fn(&X::g4)(&x, 1, 2, 3, 4);
mem_fn(&X::g4)(pcx, 1, 2, 3, 4);
mem_fn(&X::g4)(sp, 1, 2, 3, 4);
mem_fn(&X::f5)(x, 1, 2, 3, 4, 5);
mem_fn(&X::f5)(&x, 1, 2, 3, 4, 5);
mem_fn(&X::f5)(sp, 1, 2, 3, 4, 5);
mem_fn(&X::g5)(x, 1, 2, 3, 4, 5);
mem_fn(&X::g5)(rcx, 1, 2, 3, 4, 5);
mem_fn(&X::g5)(&x, 1, 2, 3, 4, 5);
mem_fn(&X::g5)(pcx, 1, 2, 3, 4, 5);
mem_fn(&X::g5)(sp, 1, 2, 3, 4, 5);
mem_fn(&X::f6)(x, 1, 2, 3, 4, 5, 6);
mem_fn(&X::f6)(&x, 1, 2, 3, 4, 5, 6);
mem_fn(&X::f6)(sp, 1, 2, 3, 4, 5, 6);
mem_fn(&X::g6)(x, 1, 2, 3, 4, 5, 6);
mem_fn(&X::g6)(rcx, 1, 2, 3, 4, 5, 6);
mem_fn(&X::g6)(&x, 1, 2, 3, 4, 5, 6);
mem_fn(&X::g6)(pcx, 1, 2, 3, 4, 5, 6);
mem_fn(&X::g6)(sp, 1, 2, 3, 4, 5, 6);
mem_fn(&X::f7)(x, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::f7)(&x, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::f7)(sp, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::g7)(x, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::g7)(rcx, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::g7)(&x, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::g7)(pcx, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::g7)(sp, 1, 2, 3, 4, 5, 6, 7);
mem_fn(&X::f8)(x, 1, 2, 3, 4, 5, 6, 7, 8);
mem_fn(&X::f8)(&x, 1, 2, 3, 4, 5, 6, 7, 8);
mem_fn(&X::f8)(sp, 1, 2, 3, 4, 5, 6, 7, 8);
mem_fn(&X::g8)(x, 1, 2, 3, 4, 5, 6, 7, 8);
mem_fn(&X::g8)(rcx, 1, 2, 3, 4, 5, 6, 7, 8);
mem_fn(&X::g8)(&x, 1, 2, 3, 4, 5, 6, 7, 8);
mem_fn(&X::g8)(pcx, 1, 2, 3, 4, 5, 6, 7, 8);
mem_fn(&X::g8)(sp, 1, 2, 3, 4, 5, 6, 7, 8);
return detect_errors(x.hash == 17610 && sp->hash == 2155);
}

View File

@@ -17,7 +17,7 @@
<td align="center">
<table border="0">
<tr><td nowrap><h1>ref.hpp</h1></td></tr>
<tr><td align="right" nowrap><small>&nbsp;1.00.0003 (2001-08-22)</small></td></tr>
<tr><td align="right" nowrap><small>&nbsp;1.00.0004 (2002-01-27)</small></td></tr>
</table>
</td>
</tr>
@@ -35,8 +35,9 @@
<p>
The header <a href="../../boost/ref.hpp">boost/ref.hpp</a> defines the class template
<b>boost::reference_wrapper&lt;T&gt;</b> and the two functions <b>boost::ref</b> and
<b>boost::cref</b> that return instances of <b>boost::reference_wrapper&lt;T&gt;</b>.
<b>boost::reference_wrapper&lt;T&gt;</b>, the two functions <b>boost::ref</b> and
<b>boost::cref</b> that return instances of
<b>boost::reference_wrapper&lt;T&gt;</b>, and the two traits classes <b>boost::is_reference_wrapper&lt;T&gt;</b> and <b>boost::unwrap_reference&lt;T&gt;</b>.
</p>
<p>
@@ -52,8 +53,8 @@ work on references unmodified.
</p>
<p>
<b>boost::reference_wrapper&lt;T&gt;</b> is <b>CopyConstructible</b>, but it is not
<b>Assignable</b>.
<b>boost::reference_wrapper&lt;T&gt;</b> is both <b>CopyConstructible</b> and
<b>Assignable</b> (ordinary references are not <b>Assignable</b>).
</p>
<p>
@@ -62,6 +63,14 @@ where <b>X</b> is the type of <b>x</b>. Similarly, <b>boost::cref(x)</b>
returns a <b>boost::reference_wrapper&lt;X const&gt;(x)</b>.
</p>
<p>The expression <b>boost::is_reference_wrapper&lt;T&gt;::value</b> is
<b>true</b> if <b>T</b> is a
<b>reference_wrapper</b>, and <b>false</b> otherwise.
<p>The type-expression <b>boost::unwrap_reference&lt;T&gt;::type</b>
is <b>T::type</b> if <b>T</b> is a
<b>reference_wrapper</b>, <b>T</b> otherwise.
<h2>Interface</h2>
<h3>Synopsis</h3>
@@ -72,6 +81,8 @@ namespace boost
template&lt;class T&gt; class <a href="#reference_wrapper">reference_wrapper</a>;
template&lt;class T&gt; reference_wrapper&lt;T&gt; <a href="#ref">ref</a>(T &amp; t);
template&lt;class T&gt; reference_wrapper&lt;T const&gt; <a href="#cref">cref</a>(T const &amp; t);
template&lt;class T&gt; class is_reference_wrapper&lt;T const&gt;;
template&lt;class T&gt; class unwrap_reference&lt;T const&gt;;
}
</pre>
@@ -81,6 +92,7 @@ namespace boost
template&lt;class T&gt; class reference_wrapper
{
public:
typedef T type;
explicit <a href="#rt_construct">reference_wrapper</a>(T &amp; t);
@@ -92,30 +104,36 @@ public:
<h4><a name="rt_construct">explicit reference_wrapper(T &amp; t)</a></h4>
<blockquote>
<p>
<b>Effects:</b> Constructs a <b>reference_wrapper</b> object that stores a reference to <b>t</b>.
</p>
<p>
<b>Throws:</b> Nothing.
</p>
</blockquote>
<h4><a name="rt_operator">operator T &amp; () const</a></h4>
<blockquote>
<p>
<b>Returns:</b> the stored reference.
</p>
<p>
<b>Throws:</b> Nothing.
</p>
</blockquote>
<h4><a name="rt_get">T &amp; get() const</a></h4>
<blockquote>
<p>
<b>Returns:</b> the stored reference.
</p>
<p>
<b>Throws:</b> Nothing.
</p>
</blockquote>
<h3><a name="ref">ref</a></h3>
@@ -123,12 +141,14 @@ public:
template&lt;class T&gt; reference_wrapper&lt;T&gt; ref(T &amp; t);
</pre>
<blockquote>
<p>
<b>Returns:</b> <tt>reference_wrapper&lt;T&gt;(t)</tt>.
</p>
<p>
<b>Throws:</b> Nothing.
</p>
</blockquote>
<h3><a name="cref">cref</a></h3>
@@ -136,19 +156,47 @@ template&lt;class T&gt; reference_wrapper&lt;T&gt; ref(T &amp; t);
template&lt;class T&gt; reference_wrapper&lt;T const&gt; cref(T const &amp; t);
</pre>
<blockquote>
<p>
<b>Returns:</b> <tt>reference_wrapper&lt;T const&gt;(t)</tt>.
</p>
<p>
<b>Throws:</b> Nothing.
</p>
</blockquote>
<h3><a name="is_reference_wrapper">is_reference_wrapper</a></h3>
<pre>
template&lt;class T&gt; class is_reference_wrapper&lt;T const&gt;
{
public:
static bool value = <i>unspecified</i>;
};
</pre>
Value is <b>true</b> iff <tt>T</tt> is a specialization of <tt>reference_wrapper</tt>.
<h3><a name="unwrap_reference">unwrap_reference</a></h3>
<pre>
template&lt;class T&gt; class unwrap_reference&lt;T const&gt;
{
public:
typedef <i>unspecified</i> type;
};
</pre>
<tt>type</tt> is equivalent to <tt>T::type</tt> if <tt>T</tt> is a specialization of <tt>reference_wrapper</tt>. Otherwise <tt>type</tt> is equivalent to <tt>T</tt>.
<h2>Acknowledgements</h2>
<p>
<b>ref</b> and <b>cref</b> were originally part of the Boost.Tuple library.
They were "promoted to <b>boost::</b> status" because they are generally
useful.
<b>ref</b> and <b>cref</b> were originally part of the Boost.Tuple
library by <a href="../../people/jaakko_jarvi.htm"> Jaakko
J&auml;rvi</a>. They were "promoted to <b>boost::</b> status" by <a
href="../../people/peter_dimov.htm">Peter Dimov</a> because they are
generally useful. <a href="../../people/doug_gregor.html">Douglas
Gregor</a> and <a href="../../people/dave_abrahams.htm">Dave
Abrahams</a> contributed <tt>is_reference_wrapper</tt> and
<tt>unwrap_reference</tt>.
</p>