mirror of
https://github.com/boostorg/bind.git
synced 2026-04-19 07:58:53 +02:00
Compare commits
3 Commits
boost-1.37
...
boost-1.33
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8ab7e1b98 | ||
|
|
8d6f2373c2 | ||
|
|
232bb39198 |
513
bind.html
513
bind.html
@@ -7,7 +7,7 @@
|
|||||||
<body style="MARGIN-LEFT: 5%; MARGIN-RIGHT: 5%" bgColor="white">
|
<body style="MARGIN-LEFT: 5%; MARGIN-RIGHT: 5%" bgColor="white">
|
||||||
<table width="100%" border="0">
|
<table width="100%" border="0">
|
||||||
<tr>
|
<tr>
|
||||||
<td width="277"><A href="../../index.htm"><IMG height="86" alt="boost.png (6897 bytes)" src="../../boost.png" width="277" border="0"></A>
|
<td width="277"><IMG height="86" alt="boost.png (6897 bytes)" src="../../boost.png" width="277">
|
||||||
</td>
|
</td>
|
||||||
<td align="center">
|
<td align="center">
|
||||||
<h1>bind.hpp</h1>
|
<h1>bind.hpp</h1>
|
||||||
@@ -19,54 +19,53 @@
|
|||||||
</table>
|
</table>
|
||||||
<h2>Contents</h2>
|
<h2>Contents</h2>
|
||||||
<h3 style="MARGIN-LEFT: 20pt"><A href="#Purpose">Purpose</A></h3>
|
<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
|
<h4 style="MARGIN-LEFT: 40pt"><A href="#with_functions">Using bind with functions and
|
||||||
function pointers</A></h4>
|
function pointers</A></h4>
|
||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#with_function_objects">Using bind with function
|
<h4 style="MARGIN-LEFT: 40pt"><A href="#with_function_objects">Using bind with function
|
||||||
objects</A></h4>
|
objects</A></h4>
|
||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#with_member_pointers">Using bind with pointers
|
<h4 style="MARGIN-LEFT: 40pt"><A href="#with_member_pointers">Using bind with pointers
|
||||||
to members</A></h4>
|
to members</A></h4>
|
||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#nested_binds">Using nested binds for function
|
<h4 style="MARGIN-LEFT: 40pt"><A href="#nested_binds">Using nested binds for function
|
||||||
composition</A></h4>
|
composition</A></h4>
|
||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#operators">Overloaded operators</A></h4>
|
<h4 style="MARGIN-LEFT: 40pt"><A href="#operators">Overloaded operators</A></h4>
|
||||||
<h3 style="MARGIN-LEFT: 20pt"><A href="#Examples">Examples</A></h3>
|
<h3 style="MARGIN-LEFT: 20pt"><A href="#Examples">Examples</A></h3>
|
||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#with_algorithms">Using bind with standard
|
<h4 style="MARGIN-LEFT: 40pt"><A href="#with_algorithms">Using bind with standard
|
||||||
algorithms</A></h4>
|
algorithms</A></h4>
|
||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#with_boost_function">Using bind with
|
<h4 style="MARGIN-LEFT: 40pt"><A href="#with_boost_function">Using bind with
|
||||||
Boost.Function</A></h4>
|
Boost.Function</A></h4>
|
||||||
<h3 style="MARGIN-LEFT: 20pt"><A href="#Limitations">Limitations</A></h3>
|
<h3 style="MARGIN-LEFT: 20pt"><A href="#Limitations">Limitations</A></h3>
|
||||||
<h3 style="MARGIN-LEFT: 20pt"><A href="#FAQ">Frequently Asked Questions</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_doesnt_compile">Why doesn't this compile?</A></h4>
|
||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#Q_does_compile">Why does this compile? It
|
<h4 style="MARGIN-LEFT: 40pt"><A href="#Q_does_compile">Why does this compile? It
|
||||||
should not.</A></h4>
|
should not.</A></h4>
|
||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#Q_forms">What is the difference between bind(f,
|
<h4 style="MARGIN-LEFT: 40pt"><A href="#Q_forms">What is the difference between bind(f,
|
||||||
...) and bind<R>(f, ...)?</A></h4>
|
...) and bind<R>(f, ...)?</A></h4>
|
||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#Q_win32_api">Does <b>bind</b> work with Windows
|
<h4 style="MARGIN-LEFT: 40pt"><A href="#Q_win32_api">Does <b>bind</b> work with Windows
|
||||||
API functions?</A></h4>
|
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_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
|
<h4 style="MARGIN-LEFT: 40pt"><A href="#Q_mac">Does <b>bind</b> work with Mac toolbox
|
||||||
functions?</A></h4>
|
functions?</A></h4>
|
||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#Q_extern_C">Does <b>bind</b> work with extern
|
<h4 style="MARGIN-LEFT: 40pt"><A href="#Q_extern_C">Does <b>bind</b> work with extern
|
||||||
"C" functions?</A></h4>
|
"C" functions?</A></h4>
|
||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#Q_auto_stdcall">Why doesn't <b>bind</b> automatically
|
<h4 style="MARGIN-LEFT: 40pt"><A href="#Q_auto_stdcall">Why doesn't <b>bind</b> automatically
|
||||||
recognize nonstandard functions?</A></h4>
|
recognize nonstandard functions?</A></h4>
|
||||||
<h3 style="MARGIN-LEFT: 20pt"><A href="#Troubleshooting">Troubleshooting</A></h3>
|
<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_num_args">Incorrect number of arguments</A></h4>
|
||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_signature">The function object cannot be
|
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_signature">The function object cannot be
|
||||||
called with the specified arguments</A></h4>
|
called with the specified arguments</A></h4>
|
||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_arg_access">Accessing an argument that does
|
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_arg_access">Accessing an argument that does
|
||||||
not exist</A></h4>
|
not exist</A></h4>
|
||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_short_form">Inappropriate use of bind(f,
|
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_short_form">Inappropriate use of bind(f,
|
||||||
...)</A></h4>
|
...)</A></h4>
|
||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_long_form">Inappropriate use of
|
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_long_form">Inappropriate use of
|
||||||
bind<R>(f, ...)</A></h4>
|
bind<R>(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_nonstd">Binding a nonstandard function</A></h4>
|
||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_overloaded">Binding an overloaded 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_const_arg"><b>const</b> in signatures</A></h4>
|
||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_msvc_using">MSVC specific: using
|
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_msvc_using">MSVC specific: using
|
||||||
boost::bind;</A></h4>
|
boost::bind;</A></h4>
|
||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_msvc_class_template">MSVC specific: class
|
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_msvc_class_template">MSVC specific: class
|
||||||
templates shadow function templates</A></h4>
|
templates shadow function templates</A></h4>
|
||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_msvc_ellipsis">MSVC specific: ... in
|
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_msvc_ellipsis">MSVC specific: ... in
|
||||||
signatures treated as type</A></h4>
|
signatures treated as type</A></h4>
|
||||||
<h3 style="MARGIN-LEFT: 20pt"><A href="#Interface">Interface</A></h3>
|
<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="#Synopsis">Synopsis</A></h4>
|
||||||
@@ -78,16 +77,16 @@
|
|||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#Files">Files</A></h4>
|
<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="#Dependencies">Dependencies</A></h4>
|
||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#NumberOfArguments">Number of Arguments</A></h4>
|
<h4 style="MARGIN-LEFT: 40pt"><A href="#NumberOfArguments">Number of Arguments</A></h4>
|
||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#stdcall">"__stdcall", "__cdecl", "__fastcall",
|
<h4 style="MARGIN-LEFT: 40pt"><A href="#stdcall">"__stdcall", "__cdecl", "__fastcall",
|
||||||
and "pascal" Support</A></h4>
|
and "pascal" Support</A></h4>
|
||||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#visit_each"><b>visit_each</b> support</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>
|
<h3 style="MARGIN-LEFT: 20pt"><A href="#Acknowledgements">Acknowledgements</A></h3>
|
||||||
<h2><a name="Purpose">Purpose</a></h2>
|
<h2><a name="Purpose">Purpose</a></h2>
|
||||||
<p><b>boost::bind</b> is a generalization of the standard functions <b>std::bind1st</b>
|
<p><b>boost::bind</b> is a generalization of the standard functions <b>std::bind1st</b>
|
||||||
and <b>std::bind2nd</b>. It supports arbitrary function objects, functions,
|
and <b>std::bind2nd</b>. It supports arbitrary function objects, functions,
|
||||||
function pointers, and member function pointers, and is able to bind any
|
function pointers, and member function pointers, and is able to bind any
|
||||||
argument to a specific value or route input arguments into arbitrary positions. <b>bind</b>
|
argument to a specific value or route input arguments into arbitrary positions. <b>bind</b>
|
||||||
does not place any requirements on the function object; in particular, it does
|
does not place any requirements on the function object; in particular, it does
|
||||||
not need the <b>result_type</b>, <b>first_argument_type</b> and <b>second_argument_type</b>
|
not need the <b>result_type</b>, <b>first_argument_type</b> and <b>second_argument_type</b>
|
||||||
standard typedefs.
|
standard typedefs.
|
||||||
</p>
|
</p>
|
||||||
@@ -104,15 +103,15 @@ int g(int a, int b, int c)
|
|||||||
return a + b + c;
|
return a + b + c;
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
<p><tt>bind(f, 1, 2)</tt> will produce a "nullary" function object that takes no
|
<p><tt>bind(f, 1, 2)</tt> will produce a "nullary" function object that takes no
|
||||||
arguments and returns <tt>f(1, 2)</tt>. Similarly, <tt>bind(g, 1, 2, 3)()</tt> is
|
arguments and returns <tt>f(1, 2)</tt>. Similarly, <tt>bind(g, 1, 2, 3)()</tt> is
|
||||||
equivalent to <tt>g(1, 2, 3)</tt>.
|
equivalent to <tt>g(1, 2, 3)</tt>.
|
||||||
</p>
|
</p>
|
||||||
<p>It is possible to selectively bind only some of the arguments. <tt>bind(f, _1, 5)(x)</tt>
|
<p>It is possible to selectively bind only some of the arguments. <tt>bind(f, _1, 5)(x)</tt>
|
||||||
is equivalent to <tt>f(x, 5)</tt>; here <b>_1</b>
|
is equivalent to <tt>f(x, 5)</tt>; here <b>_1</b>
|
||||||
is a placeholder argument that means "substitute with the first input
|
is a placeholder argument that means "substitute with the first input
|
||||||
argument."
|
argument."
|
||||||
<p>For comparison, here is the same operation expressed with the standard library
|
<p>For comparison, here is the same operation expressed with the standard library
|
||||||
primitives:
|
primitives:
|
||||||
</p>
|
</p>
|
||||||
<pre>std::bind2nd(std::ptr_fun(f), 5)(x);
|
<pre>std::bind2nd(std::ptr_fun(f), 5)(x);
|
||||||
@@ -122,7 +121,7 @@ int g(int a, int b, int c)
|
|||||||
<pre>std::bind1st(std::ptr_fun(f), 5)(x); // f(5, x)
|
<pre>std::bind1st(std::ptr_fun(f), 5)(x); // f(5, x)
|
||||||
bind(f, 5, _1)(x); // f(5, x)
|
bind(f, 5, _1)(x); // f(5, x)
|
||||||
</pre>
|
</pre>
|
||||||
<p><b>bind</b> can handle functions with more than two arguments, and its argument
|
<p><b>bind</b> can handle functions with more than two arguments, and its argument
|
||||||
substitution mechanism is more general:
|
substitution mechanism is more general:
|
||||||
</p>
|
</p>
|
||||||
<pre>bind(f, _2, _1)(x, y); // f(y, x)
|
<pre>bind(f, _2, _1)(x, y); // f(y, x)
|
||||||
@@ -133,13 +132,13 @@ bind(g, _3, _3, _3)(x, y, z); // g(z, z, z)
|
|||||||
|
|
||||||
bind(g, _1, _1, _1)(x, y, z); // g(x, x, x)
|
bind(g, _1, _1, _1)(x, y, z); // g(x, x, x)
|
||||||
</pre>
|
</pre>
|
||||||
<p>Note that, in the last example, the function object produced by <tt>bind(g, _1, _1,
|
<p>Note that, in the last example, the function object produced by <tt>bind(g, _1, _1,
|
||||||
_1)</tt> does not contain references to any arguments beyond the first, but
|
_1)</tt> does not contain references to any arguments beyond the first, but
|
||||||
it can still be used with more than one argument. Any extra arguments are
|
it can still be used with more than one argument. Any extra arguments are
|
||||||
silently ignored, just like the first and the second argument are ignored in
|
silently ignored, just like the first and the second argument are ignored in
|
||||||
the third example.
|
the third example.
|
||||||
</p>
|
</p>
|
||||||
<p>The arguments that <b>bind</b> takes are copied and held internally by the
|
<p>The arguments that <b>bind</b> takes are copied and held internally by the
|
||||||
returned function object. For example, in the following code:
|
returned function object. For example, in the following code:
|
||||||
</p>
|
</p>
|
||||||
<pre>int i = 5;
|
<pre>int i = 5;
|
||||||
@@ -147,7 +146,7 @@ bind(g, _1, _1, _1)(x, y, z); // g(x, x, x)
|
|||||||
bind(f, i, _1);
|
bind(f, i, _1);
|
||||||
</pre>
|
</pre>
|
||||||
<p>a copy of the value of <b>i</b> is stored into the function object. <A href="ref.html">
|
<p>a copy of the value of <b>i</b> is stored into the function object. <A href="ref.html">
|
||||||
boost::ref</A> and <A href="ref.html">boost::cref</A> can be used to make
|
boost::ref</A> and <A href="ref.html">boost::cref</A> can be used to make
|
||||||
the function object store a reference to an object, rather than a copy:
|
the function object store a reference to an object, rather than a copy:
|
||||||
</p>
|
</p>
|
||||||
<pre>int i = 5;
|
<pre>int i = 5;
|
||||||
@@ -157,9 +156,9 @@ bind(f, ref(i), _1);
|
|||||||
bind(f, cref(42), _1);
|
bind(f, cref(42), _1);
|
||||||
</pre>
|
</pre>
|
||||||
<h3><a name="with_function_objects">Using bind with function objects</a></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.
|
<p><b>bind</b> is not limited to functions; it accepts arbitrary function objects.
|
||||||
In the general case, the return type of the generated function object's <b>operator()</b>
|
In the general case, the return type of the generated function object's <b>operator()</b>
|
||||||
has to be specified explicitly (without a <b>typeof</b> operator the return
|
has to be specified explicitly (without a <b>typeof</b> operator the return
|
||||||
type cannot be inferred):
|
type cannot be inferred):
|
||||||
</p>
|
</p>
|
||||||
<pre>struct F
|
<pre>struct F
|
||||||
@@ -174,13 +173,13 @@ int x = 104;
|
|||||||
|
|
||||||
bind<int>(f, _1, _1)(x); // f(x, x), i.e. zero
|
bind<int>(f, _1, _1)(x); // f(x, x), i.e. zero
|
||||||
</pre>
|
</pre>
|
||||||
<p>Some compilers have trouble with the <tt>bind<R>(f, ...)</tt> syntax. For
|
<p>Some compilers have trouble with the <tt>bind<R>(f, ...)</tt> syntax. For
|
||||||
portability reasons, an alternative way to express the above is supported:</p>
|
portability reasons, an alternative way to express the above is supported:</p>
|
||||||
<pre>boost::bind(boost::type<int>(), f, _1, _1)(x);
|
<pre>boost::bind(boost::type<int>(), f, _1, _1)(x);
|
||||||
</pre>
|
</pre>
|
||||||
<P>Note, however, that the alternative syntax is provided only as a workaround. It
|
<P>Note, however, that the alternative syntax is provided only as a workaround. It
|
||||||
is not part of the interface.</P>
|
is not part of the interface.</P>
|
||||||
<P>When the function object exposes a nested type named <b>result_type</b>, the
|
<P>When the function object exposes a nested type named <b>result_type</b>, the
|
||||||
explicit return type can be omitted:
|
explicit return type can be omitted:
|
||||||
</P>
|
</P>
|
||||||
<pre>int x = 8;
|
<pre>int x = 8;
|
||||||
@@ -189,32 +188,11 @@ bind(std::less<int>(), _1, 9)(x); // x < 9
|
|||||||
</pre>
|
</pre>
|
||||||
<p>[Note: the ability to omit the return type is not available on all compilers.]
|
<p>[Note: the ability to omit the return type is not available on all compilers.]
|
||||||
</p>
|
</p>
|
||||||
<P>By default, <STRONG>bind</STRONG> makes a copy of the provided function object. <code>
|
|
||||||
boost::ref</code> and <code>boost::cref</code> can be used to make it store
|
|
||||||
a reference to the function object, rather than a copy. This can be useful when
|
|
||||||
the function object is noncopyable, expensive to copy, or contains state; of
|
|
||||||
course, in this case the programmer is expected to ensure that the function
|
|
||||||
object is not destroyed while it's still being used.</P>
|
|
||||||
<pre>struct F2
|
|
||||||
{
|
|
||||||
int s;
|
|
||||||
|
|
||||||
typedef void result_type;
|
|
||||||
void operator()( int x ) { s += x; }
|
|
||||||
};
|
|
||||||
|
|
||||||
F2 f2 = { 0 };
|
|
||||||
int a[] = { 1, 2, 3 };
|
|
||||||
|
|
||||||
std::for_each( a, a+3, bind( ref(f2), _1 ) );
|
|
||||||
|
|
||||||
assert( f2.s == 6 );
|
|
||||||
</pre>
|
|
||||||
<h3><a name="with_member_pointers">Using bind with pointers to members</a></h3>
|
<h3><a name="with_member_pointers">Using bind with pointers to members</a></h3>
|
||||||
<p>Pointers to member functions and pointers to data members are not function
|
<p>Pointers to member functions and pointers to data members are not function
|
||||||
objects, because they do not support <tt>operator()</tt>. For convenience, <b>bind</b>
|
objects, because they do not support <tt>operator()</tt>. For convenience, <b>bind</b>
|
||||||
accepts member pointers as its first argument, and the behavior is as if <A href="mem_fn.html">
|
accepts member pointers as its first argument, and the behavior is as if <A href="mem_fn.html">
|
||||||
boost::mem_fn</A> has been used to convert the member pointer into a
|
boost::mem_fn</A> has been used to convert the member pointer into a
|
||||||
function object. In other words, the expression
|
function object. In other words, the expression
|
||||||
</p>
|
</p>
|
||||||
<pre>bind(&X::f, <i>args</i>)
|
<pre>bind(&X::f, <i>args</i>)
|
||||||
@@ -223,11 +201,11 @@ assert( f2.s == 6 );
|
|||||||
</p>
|
</p>
|
||||||
<pre>bind<R>(<A href="mem_fn.html" >mem_fn</A>(&X::f), <i>args</i>)
|
<pre>bind<R>(<A href="mem_fn.html" >mem_fn</A>(&X::f), <i>args</i>)
|
||||||
</pre>
|
</pre>
|
||||||
<p>where <b>R</b> is the return type of <b>X::f</b> (for member functions) or the
|
<p>where <b>R</b> is the return type of <b>X::f</b> (for member functions) or the
|
||||||
type of the member (for data members.)
|
type of the member (for data members.)
|
||||||
</p>
|
</p>
|
||||||
<p>[Note: <b>mem_fn</b> creates function objects that are able to accept a pointer,
|
<p>[Note: <b>mem_fn</b> creates function objects that are able to accept a pointer,
|
||||||
a reference, or a smart pointer to an object as its first argument; for
|
a reference, or a smart pointer to an object as its first argument; for
|
||||||
additional information, see the <b>mem_fn</b> <A href="mem_fn.html">documentation</A>.]
|
additional information, see the <b>mem_fn</b> <A href="mem_fn.html">documentation</A>.]
|
||||||
</p>
|
</p>
|
||||||
<p>Example:
|
<p>Example:
|
||||||
@@ -248,33 +226,33 @@ bind(&X::f, &x, _1)(i); //(&x)->f(i)
|
|||||||
bind(&X::f, x, _1)(i); // (<i>internal copy of x</i>).f(i)
|
bind(&X::f, x, _1)(i); // (<i>internal copy of x</i>).f(i)
|
||||||
bind(&X::f, p, _1)(i); // (<i>internal copy of p</i>)->f(i)
|
bind(&X::f, p, _1)(i); // (<i>internal copy of p</i>)->f(i)
|
||||||
</pre>
|
</pre>
|
||||||
<p>The last two examples are interesting in that they produce "self-contained"
|
<p>The last two examples are interesting in that they produce "self-contained"
|
||||||
function objects. <tt>bind(&X::f, x, _1)</tt> stores a copy of <b>x</b>. <tt>bind(&X::f,
|
function objects. <tt>bind(&X::f, x, _1)</tt> stores a copy of <b>x</b>. <tt>bind(&X::f,
|
||||||
p, _1)</tt> stores a copy of <b>p</b>, and since <b>p</b> is a <A href="../smart_ptr/shared_ptr.htm">
|
p, _1)</tt> stores a copy of <b>p</b>, and since <b>p</b> is a <A href="../smart_ptr/shared_ptr.htm">
|
||||||
boost::shared_ptr</A>, the function object retains a reference to its
|
boost::shared_ptr</A>, 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
|
instance of <b>X</b> and will remain valid even when <b>p</b> goes out of scope
|
||||||
or is <b>reset()</b>.
|
or is <b>reset()</b>.
|
||||||
</p>
|
</p>
|
||||||
<h3><a name="nested_binds">Using nested binds for function composition</a></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
|
<p>Some of the arguments passed to <b>bind</b> may be nested <b>bind</b> expressions
|
||||||
themselves:
|
themselves:
|
||||||
</p>
|
</p>
|
||||||
<pre>bind(f, bind(g, _1))(x); // f(g(x))
|
<pre>bind(f, bind(g, _1))(x); // f(g(x))
|
||||||
</pre>
|
</pre>
|
||||||
<p>The inner <STRONG>bind</STRONG> expressions are evaluated, in unspecified order,
|
<p>The inner <STRONG>bind</STRONG> expressions are evaluated, in unspecified order,
|
||||||
before the outer <STRONG>bind</STRONG> when the function object is called; the
|
before the outer <STRONG>bind</STRONG> when the function object is called; the
|
||||||
results of the evaluation are then substituted in their place when the outer <STRONG>
|
results of the evaluation are then substituted in their place when the outer <STRONG>
|
||||||
bind</STRONG> is evaluated. In the example above, when the function object
|
bind</STRONG> is evaluated. In the example above, when the function object
|
||||||
is called with the argument list <tt>(x)</tt>, <tt>bind(g, _1)(x)</tt> is
|
is called with the argument list <tt>(x)</tt>, <tt>bind(g, _1)(x)</tt> is
|
||||||
evaluated first, yielding <tt>g(x)</tt>, and then <tt>bind(f, g(x))(x)</tt> is
|
evaluated first, yielding <tt>g(x)</tt>, and then <tt>bind(f, g(x))(x)</tt> is
|
||||||
evaluated, yielding the final result <tt>f(g(x))</tt>.
|
evaluated, yielding the final result <tt>f(g(x))</tt>.
|
||||||
</p>
|
</p>
|
||||||
<P>This feature of <b>bind</b> can be used to perform function composition. See <A href="bind_as_compose.cpp">
|
<P>This feature of <b>bind</b> can be used to perform function composition. See <A href="bind_as_compose.cpp">
|
||||||
bind_as_compose.cpp</A> for an example that demonstrates how to use <b>bind</b>
|
bind_as_compose.cpp</A> for an example that demonstrates how to use <b>bind</b>
|
||||||
to achieve similar functionality to <A href="../compose/index.htm">Boost.Compose</A>.
|
to achieve similar functionality to <A href="../compose/index.htm">Boost.Compose</A>.
|
||||||
</P>
|
</P>
|
||||||
<p>Note that the first argument - the bound function object - is not evaluated,
|
<p>Note that the first argument - the bound function object - is not evaluated,
|
||||||
even when it's a function object that is produced by <STRONG>bind</STRONG> or a
|
even when it's a function object that is produced by <STRONG>bind</STRONG> or a
|
||||||
placeholder argument, so the example below does not work as expected:
|
placeholder argument, so the example below does not work as expected:
|
||||||
</p>
|
</p>
|
||||||
<pre>typedef void (*pf)(int);
|
<pre>typedef void (*pf)(int);
|
||||||
@@ -284,9 +262,9 @@ std::vector<pf> v;
|
|||||||
std::for_each(v.begin(), v.end(), bind(_1, 5));
|
std::for_each(v.begin(), v.end(), bind(_1, 5));
|
||||||
</pre>
|
</pre>
|
||||||
<p>The desired effect can be achieved via a helper function object <STRONG>apply</STRONG>
|
<p>The desired effect can be achieved via a helper function object <STRONG>apply</STRONG>
|
||||||
that applies its first argument, as a function object, to the rest of its
|
that applies its first argument, as a function object, to the rest of its
|
||||||
argument list. For convenience, an implementation of <STRONG>apply</STRONG> is
|
argument list. For convenience, an implementation of <STRONG>apply</STRONG> is
|
||||||
provided in the <STRONG>boost/bind/apply.hpp</STRONG> header file. Here is how
|
provided in the <STRONG>boost/bind/apply.hpp</STRONG> header file. Here is how
|
||||||
the modified version of the previous example looks like:
|
the modified version of the previous example looks like:
|
||||||
</p>
|
</p>
|
||||||
<pre>typedef void (*pf)(int);
|
<pre>typedef void (*pf)(int);
|
||||||
@@ -295,39 +273,38 @@ std::vector<pf> v;
|
|||||||
|
|
||||||
std::for_each(v.begin(), v.end(), bind(apply<void>(), _1, 5));
|
std::for_each(v.begin(), v.end(), bind(apply<void>(), _1, 5));
|
||||||
</pre>
|
</pre>
|
||||||
<P>Although the first argument is, by default, not evaluated, all other arguments
|
<P>Although the first argument is, by default, not evaluated, all other arguments
|
||||||
are. Sometimes it is necessary not to evaluate arguments subsequent to the
|
are. Sometimes it is necessary not to evaluate arguments subsequent to the
|
||||||
first, even when they are nested <STRONG>bind</STRONG> subexpressions. This can
|
first, even when they are nested <STRONG>bind</STRONG> subexpressions. This can
|
||||||
be achieved with the help of another function object, <STRONG>protect</STRONG>,
|
be achieved with the help of another function object, <STRONG>protect</STRONG>,
|
||||||
that masks the type so that <STRONG>bind</STRONG> does not recognize and
|
that masks the type so that <STRONG>bind</STRONG> does not recognize and
|
||||||
evaluate it. When called, <STRONG>protect</STRONG> simply forwards the argument
|
evaluate it. When called, <STRONG>protect</STRONG> simply forwards the argument
|
||||||
list to the other function object unmodified.</P>
|
list to the other function object unmodified.</P>
|
||||||
<P>The header <STRONG>boost/bind/protect.hpp</STRONG> contains an implementation of <STRONG>
|
<P>The header <STRONG>boost/bind/protect.hpp</STRONG> contains an implementation of <STRONG>
|
||||||
protect</STRONG>. To protect a <STRONG>bind</STRONG> function object from
|
protect</STRONG>. To protect a <STRONG>bind</STRONG> function object from
|
||||||
evaluation, use <tt>protect(bind(f, ...))</tt>.</P>
|
evaluation, use <tt>protect(bind(f, ...))</tt>.</P>
|
||||||
<h3><a name="operators">Overloaded operators</a> (new in Boost 1.33)</h3>
|
<h3><a name="operators">Overloaded operators</a> (new in Boost 1.33)</h3>
|
||||||
<p>For convenience, the function objects produced by <tt>bind</tt> overload the
|
<p>For convenience, the function objects produced by <tt>bind</tt> overload
|
||||||
logical not operator <code>!</code> and the relational and logical operators <code>==</code>,
|
the logical not operator <STRONG>!</STRONG> and the relational operators <STRONG>==</STRONG>,
|
||||||
<code>!=</code>, <code><</code>, <code><=</code>, <code>></code>, <code>>=</code>,
|
<STRONG>!=</STRONG>, <STRONG><</STRONG>, <STRONG><=</STRONG>, <STRONG>></STRONG>,
|
||||||
<code>&&</code>, <code>||</code>.</p>
|
<STRONG>>=</STRONG>.</p>
|
||||||
<P><tt>!bind(f, ...)</tt> is equivalent to <tt>bind( <EM>logical_not</EM>(), bind(f,
|
<P><tt>!bind(f, ...)</tt> is equivalent to <tt>bind( <EM>logical_not</EM>(), bind(f,
|
||||||
...) )</tt>, where <tt><EM>logical_not</EM></tt> is a function object that
|
...) )</tt>, where <tt><EM>logical_not</EM></tt> is a function object that
|
||||||
takes one argument <tt>x</tt> and returns <tt>!x</tt>.</P>
|
takes one argument <tt>x</tt> and returns <tt>!x</tt>.</P>
|
||||||
<P><tt>bind(f, ...) <EM>op</EM> x</tt>, where <EM>op</EM> is a relational or
|
<P><tt>bind(f, ...) <EM>op</EM> x</tt>, where <EM>op</EM> is a relational operator,
|
||||||
logical operator, is equivalent to <tt>bind( <EM>relation</EM>(), bind(f, ...), x )</tt>,
|
is equivalent to <tt>bind( <EM>relation</EM>(), bind(f, ...), x )</tt>, where <em>relation</em>
|
||||||
where <em>relation</em> is a function object that takes two arguments <tt>a</tt>
|
is a function object that takes two arguments <tt>a</tt> and <tt>b</tt> and
|
||||||
and <tt>b</tt> and returns <tt>a <EM>op</EM> b</tt>.</P>
|
returns <tt>a <EM>op</EM> b</tt>.</P>
|
||||||
<P>What this means in practice is that you can conveniently negate the result of <tt>bind</tt>:</P>
|
<P>What this means in practice is that you can conveniently negate the result of
|
||||||
<P><tt>std::remove_if( first, last, !bind( &X::visible, _1 ) ); // remove invisible
|
<tt>bind</tt>:</P>
|
||||||
|
<P><tt>std::remove_if( first, last, !bind( &X::visible, _1 ) ); // remove invisible
|
||||||
objects</tt></P>
|
objects</tt></P>
|
||||||
<P>and compare the result of <tt>bind</tt> against a value:</P>
|
<P>and compare the result of <tt>bind</tt> against a value:</P>
|
||||||
<P><tt>std::find_if( first, last, bind( &X::name, _1 ) == "Peter" );</tt></P>
|
<P><tt>std::find_if( first, last, bind( &X::name, _1 ) == "peter" );</tt></P>
|
||||||
<P><tt>std::find_if( first, last, bind( &X::name, _1 ) == "Peter" || bind(
|
|
||||||
&X::name, _1 ) == "Paul" );</tt></P>
|
|
||||||
<P>against a placeholder:</P>
|
<P>against a placeholder:</P>
|
||||||
<P><tt>bind( &X::name, _1 ) == _2</tt></P>
|
<P><tt>bind( &X::name, _1 ) == _2</tt></P>
|
||||||
<P>or against another <tt>bind</tt> expression:</P>
|
<P>or against another <tt>bind</tt> expression:</P>
|
||||||
<P><tt>std::sort( first, last, bind( &X::name, _1 ) < bind( &X::name, _2 )
|
<P><tt>std::sort( first, last, bind( &X::name, _1 ) < bind( &X::name, _2 )
|
||||||
); // sort by name</tt></P>
|
); // sort by name</tt></P>
|
||||||
<h2><a name="Examples">Examples</a></h2>
|
<h2><a name="Examples">Examples</a></h2>
|
||||||
<h3><a name="with_algorithms">Using bind with standard algorithms</a></h3>
|
<h3><a name="with_algorithms">Using bind with standard algorithms</a></h3>
|
||||||
@@ -365,7 +342,7 @@ void render(image & target)
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
<A href="../function/index.html" >boost::function</A><void()> onClick;
|
<A href="../function/index.html" >boost::function</A><void> onClick;
|
||||||
};
|
};
|
||||||
|
|
||||||
class player
|
class player
|
||||||
@@ -386,89 +363,87 @@ void connect()
|
|||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
<h2><a name="Limitations">Limitations</a></h2>
|
<h2><a name="Limitations">Limitations</a></h2>
|
||||||
<p>As a general rule, the function objects generated by <b>bind</b> take their
|
<p>The function objects generated by <b>bind</b> take their arguments by reference
|
||||||
arguments by reference and cannot, therefore, accept non-const temporaries or
|
and cannot, therefore, accept non-const temporaries or literal constants. This
|
||||||
literal constants. This is an inherent limitation of the C++ language in its
|
is an inherent limitation of the C++ language, known as <A href="http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm">
|
||||||
current (2003) incarnation, known as <A href="http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm">
|
the forwarding problem</A>.</p>
|
||||||
the forwarding problem</A>. (It will be fixed in the next standard, usually
|
|
||||||
called C++0x.)</p>
|
|
||||||
<p>The library uses signatures of the form
|
<p>The library uses signatures of the form
|
||||||
</p>
|
</p>
|
||||||
<pre>template<class T> void f(T & t);
|
<pre>template<class T> void f(T & t);
|
||||||
</pre>
|
</pre>
|
||||||
<p>to accept arguments of arbitrary types and pass them on unmodified. As noted,
|
<p>to accept arguments of arbitrary types and pass them on unmodified. As noted,
|
||||||
this does not work with non-const r-values.
|
this does not work with non-const r-values.
|
||||||
</p>
|
</p>
|
||||||
<p>On compilers that support partial ordering of function templates, a possible
|
<p>An oft-proposed "solution" to this problem is to add an overload:
|
||||||
solution is to add an overload:
|
|
||||||
</p>
|
</p>
|
||||||
<pre>template<class T> void f(T & t);
|
<pre>template<class T> void f(T & t);
|
||||||
template<class T> void f(T const & t);
|
template<class T> void f(T const & t);
|
||||||
</pre>
|
</pre>
|
||||||
<p>Unfortunately, this requires providing 512 overloads for nine arguments, which
|
<p>Unfortunately, this (a) requires providing 512 overloads for nine arguments and
|
||||||
is impractical. The library chooses a small subset: for up to two arguments, it
|
(b) does not actually work for const arguments, both l- and r-values, since the
|
||||||
provides the const overloads in full, for arities of three and more it provides
|
two templates produce the exact same signature and cannot be partially ordered.
|
||||||
a single additional overload with all of the arguments taken by const
|
</p>
|
||||||
reference. This covers a reasonable portion of the use cases.
|
<p>[Note: this is a dark corner of the language, and the <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#214">
|
||||||
|
corresponding issue</a> has only recently been resolved.]
|
||||||
</p>
|
</p>
|
||||||
<h2><a name="FAQ">Frequently Asked Questions</a></h2>
|
<h2><a name="FAQ">Frequently Asked Questions</a></h2>
|
||||||
<h3><a name="Q_doesnt_compile">Why doesn't this compile?</a></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>
|
<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>
|
<h3><a name="Q_does_compile">Why does this compile? It should not.</a></h3>
|
||||||
<p>Probably because you used the general <tt>bind<R>(f, ...)</tt> syntax,
|
<p>Probably because you used the general <tt>bind<R>(f, ...)</tt> syntax,
|
||||||
thereby instructing <b>bind</b> to not "inspect" <b>f</b> to detect arity and
|
thereby instructing <b>bind</b> to not "inspect" <b>f</b> to detect arity and
|
||||||
return type errors.</p>
|
return type errors.</p>
|
||||||
<h3><a name="Q_forms">What is the difference between bind(f, ...) and bind<R>(f,
|
<h3><a name="Q_forms">What is the difference between bind(f, ...) and bind<R>(f,
|
||||||
...)?</a></h3>
|
...)?</a></h3>
|
||||||
<p>The first form instructs <b>bind</b> to inspect the type of <b>f</b> in order to
|
<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
|
determine its arity (number of arguments) and return type. Arity errors will be
|
||||||
detected at "bind time". This syntax, of course, places some requirements on <b>f</b>.
|
detected at "bind time". This syntax, of course, places some requirements on <b>f</b>.
|
||||||
It must be a function, function pointer, member function pointer, or a function
|
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
|
object that defines a nested type named <b>result_type</b>; in short, it must
|
||||||
be something that <b>bind</b> can recognize.</p>
|
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
|
<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
|
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
|
cannot, expose <b>result_type</b>, but it can also be used with nonstandard
|
||||||
functions. For example, the current implementation does not automatically
|
functions. For example, the current implementation does not automatically
|
||||||
recognize variable-argument functions like <b>printf</b>, so you will have to
|
recognize variable-argument functions like <b>printf</b>, so you will have to
|
||||||
use <tt>bind<int>(printf, ...)</tt>. Note that an alternative <tt>bind(type<R>(),
|
use <tt>bind<int>(printf, ...)</tt>. Note that an alternative <tt>bind(type<R>(),
|
||||||
f, ...)</tt> syntax is supported for portability reasons.</p>
|
f, ...)</tt> syntax is supported for portability reasons.</p>
|
||||||
<p>Another important factor to consider is that compilers without partial template
|
<p>Another important factor to consider is that compilers without partial template
|
||||||
specialization or function template partial ordering support cannot handle the
|
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
|
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
|
handle the second form when <b>f</b> is a function (pointer) or a member
|
||||||
function pointer.</p>
|
function pointer.</p>
|
||||||
<h3><a name="Q_win32_api">Does <b>bind</b> work with Windows API functions?</a></h3>
|
<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
|
<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
|
alternative is to treat the function as a <A href="#with_function_objects">generic
|
||||||
function object</A> and use the <tt>bind<R>(f, ...)</tt> syntax.</p>
|
function object</A> and use the <tt>bind<R>(f, ...)</tt> syntax.</p>
|
||||||
<h3><a name="Q_com">Does <b>bind</b> work with COM methods?</a></h3>
|
<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>
|
<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>
|
<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
|
<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
|
alternative is to treat the function as a <A href="#with_function_objects">generic
|
||||||
function object</A> and use the <tt>bind<R>(f, ...)</tt> syntax.</p>
|
function object</A> and use the <tt>bind<R>(f, ...)</tt> syntax.</p>
|
||||||
<h3><a name="Q_extern_C">Does <b>bind</b> work with extern "C" functions?</a></h3>
|
<h3><a name="Q_extern_C">Does <b>bind</b> work with extern "C" functions?</a></h3>
|
||||||
<p>Sometimes. On some platforms, pointers to extern "C" functions are equivalent to
|
<p>Sometimes. On some platforms, pointers to extern "C" functions are equivalent to
|
||||||
"ordinary" function pointers, so they work fine. Other platforms treat them as
|
"ordinary" function pointers, so they work fine. Other platforms treat them as
|
||||||
different types. A platform-specific implementation of <b>bind</b> is expected
|
different types. A platform-specific implementation of <b>bind</b> is expected
|
||||||
to handle the problem transparently; this implementation does not. As usual,
|
to handle the problem transparently; this implementation does not. As usual,
|
||||||
the workaround is to treat the function as a <A href="#with_function_objects">generic
|
the workaround is to treat the function as a <A href="#with_function_objects">generic
|
||||||
function object</A> and use the <tt>bind<R>(f, ...)</tt> syntax.</p>
|
function object</A> and use the <tt>bind<R>(f, ...)</tt> syntax.</p>
|
||||||
<h3><a name="Q_auto_stdcall">Why doesn't <b>bind</b> automatically recognize
|
<h3><a name="Q_auto_stdcall">Why doesn't <b>bind</b> automatically recognize
|
||||||
nonstandard functions?</a></h3>
|
nonstandard functions?</a></h3>
|
||||||
<p>Non-portable extensions, in general, should default to off to prevent vendor
|
<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
|
lock-in. Had the <A href="#stdcall">appropriate macros</A> been defined
|
||||||
automatically, you could have accidentally taken advantage of them without
|
automatically, you could have accidentally taken advantage of them without
|
||||||
realizing that your code is, perhaps, no longer portable. In addition, some
|
realizing that your code is, perhaps, no longer portable. In addition, some
|
||||||
compilers have the option to make <b>__stdcall</b> (<STRONG>__fastcall</STRONG>)
|
compilers have the option to make <b>__stdcall</b> (<STRONG>__fastcall</STRONG>)
|
||||||
their default calling convention, in which case no separate support would be
|
their default calling convention, in which case no separate support would be
|
||||||
necessary.</p>
|
necessary.</p>
|
||||||
<h2><a name="Troubleshooting">Troubleshooting</a></h2>
|
<h2><a name="Troubleshooting">Troubleshooting</a></h2>
|
||||||
<h3><a name="err_num_args">Incorrect number of arguments</a></h3>
|
<h3><a name="err_num_args">Incorrect number of arguments</a></h3>
|
||||||
<p>In a <tt>bind(f, a1, a2, ..., aN)</tt> expression, the function object <b>f</b> must
|
<p>In a <tt>bind(f, a1, a2, ..., aN)</tt> expression, the function object <b>f</b> must
|
||||||
be able to take exactly <b>N</b> arguments. This error is normally detected at
|
be able to take exactly <b>N</b> arguments. This error is normally detected at
|
||||||
"bind time"; in other words, the compilation error is reported on the line
|
"bind time"; in other words, the compilation error is reported on the line
|
||||||
where bind() is invoked:</p>
|
where bind() is invoked:</p>
|
||||||
<pre>int f(int, int);
|
<pre>int f(int, int);
|
||||||
|
|
||||||
@@ -478,7 +453,7 @@ int main()
|
|||||||
boost::bind(f, 1, 2); // OK
|
boost::bind(f, 1, 2); // OK
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
<p>A common variation of this error is to forget that member functions have an
|
<p>A common variation of this error is to forget that member functions have an
|
||||||
implicit "this" argument:</p>
|
implicit "this" argument:</p>
|
||||||
<pre>struct X
|
<pre>struct X
|
||||||
{
|
{
|
||||||
@@ -491,10 +466,10 @@ int main()
|
|||||||
boost::bind(&X::f, <b>_1</b>, 1); // OK
|
boost::bind(&X::f, <b>_1</b>, 1); // OK
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
<h3><a name="err_signature">The function object cannot be called with the specified
|
<h3><a name="err_signature">The function object cannot be called with the specified
|
||||||
arguments</a></h3>
|
arguments</a></h3>
|
||||||
<p>As in normal function calls, the function object that is bound must be
|
<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
|
compatible with the argument list. The incompatibility will usually be detected
|
||||||
by the compiler at "call time" and the result is typically an error in <b>bind.hpp</b>
|
by the compiler at "call time" and the result is typically an error in <b>bind.hpp</b>
|
||||||
on a line that looks like:</p>
|
on a line that looks like:</p>
|
||||||
<pre> return f(a[a1_], a[a2_]);
|
<pre> return f(a[a1_], a[a2_]);
|
||||||
@@ -511,8 +486,8 @@ int main()
|
|||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
<h3><a name="err_arg_access">Accessing an argument that does not exist</a></h3>
|
<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
|
<p>The placeholder <b>_N</b> selects the argument at position <b>N</b> from the
|
||||||
argument list passed at "call time." Naturally, it is an error to attempt to
|
argument list passed at "call time." Naturally, it is an error to attempt to
|
||||||
access beyond the end of this list:</p>
|
access beyond the end of this list:</p>
|
||||||
<pre>int f(int);
|
<pre>int f(int);
|
||||||
|
|
||||||
@@ -525,68 +500,37 @@ int main()
|
|||||||
<p>The error is usually reported in <b>bind.hpp</b>, at a line similar to:</p>
|
<p>The error is usually reported in <b>bind.hpp</b>, at a line similar to:</p>
|
||||||
<pre> return f(a[a1_]);
|
<pre> return f(a[a1_]);
|
||||||
</pre>
|
</pre>
|
||||||
<p>When emulating <tt>std::bind1st(f, a)</tt>, a common mistake of this category is
|
<p>When emulating <tt>std::bind1st(f, a)</tt>, a common mistake of this category is
|
||||||
to type <tt>bind(f, a, _2)</tt> instead of the correct <tt>bind(f, a, _1)</tt>.</p>
|
to type <tt>bind(f, a, _2)</tt> instead of the correct <tt>bind(f, a, _1)</tt>.</p>
|
||||||
<h3><a name="err_short_form">Inappropriate use of bind(f, ...)</a></h3>
|
<h3><a name="err_short_form">Inappropriate use of bind(f, ...)</a></h3>
|
||||||
<p>The <tt>bind(f, a1, a2, ..., aN)</tt> <A href="#Q_forms">form</A> causes
|
<p>The <tt>bind(f, a1, a2, ..., aN)</tt> <A href="#Q_forms">form</A> causes
|
||||||
automatic recognition of the type of <b>f</b>. It will not work with arbitrary
|
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>
|
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>,
|
<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
|
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
|
ordering. In particular, MSVC up to version 7.0 does not support this syntax
|
||||||
for function objects.</p>
|
for function objects.</p>
|
||||||
<h3><a name="err_long_form">Inappropriate use of bind<R>(f, ...)</a></h3>
|
<h3><a name="err_long_form">Inappropriate use of bind<R>(f, ...)</a></h3>
|
||||||
<p>The <tt>bind<R>(f, a1, a2, ..., aN)</tt> <A href="#Q_forms">form</A> supports
|
<p>The <tt>bind<R>(f, a1, a2, ..., aN)</tt> <A href="#Q_forms">form</A> supports
|
||||||
arbitrary function objects.</p>
|
arbitrary function objects.</p>
|
||||||
<p>It is possible (but not recommended) to use this form with functions or member
|
<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.
|
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
|
In particular, MSVC up to version 7.0 does not fully support this syntax for
|
||||||
functions and member function pointers.</p>
|
functions and member function pointers.</p>
|
||||||
<h3><a name="err_nonstd">Binding a nonstandard function</a></h3>
|
<h3><a name="err_nonstd">Binding a nonstandard function</a></h3>
|
||||||
<p>By default, the <tt>bind(f, a1, a2, ..., aN)</tt> <A href="#Q_forms">form</A> recognizes
|
<p>By default, the <tt>bind(f, a1, a2, ..., aN)</tt> <A href="#Q_forms">form</A> recognizes
|
||||||
"ordinary" C++ functions and function pointers. <A href="#stdcall">Functions that
|
"ordinary" C++ functions and function pointers. <A href="#stdcall">Functions that
|
||||||
use a different calling convention</A>, or variable-argument functions such
|
use a different calling convention</A>, or variable-argument functions such
|
||||||
as <STRONG>std::printf</STRONG>, do not work. The general <tt>bind<R>(f, a1,
|
as <STRONG>std::printf</STRONG>, do not work. The general <tt>bind<R>(f, a1,
|
||||||
a2, ..., aN)</tt> <A href="#Q_forms">form</A> works with nonstandard
|
a2, ..., aN)</tt> <A href="#Q_forms">form</A> works with nonstandard
|
||||||
functions.
|
functions.
|
||||||
</p>
|
</p>
|
||||||
<p>On some platforms, extern "C" functions, like <b>std::strcmp</b>, are not
|
<p>On some platforms, extern "C" functions, like <b>std::strcmp</b>, are not
|
||||||
recognized by the short form of bind.
|
recognized by the short form of bind.
|
||||||
</p>
|
</p>
|
||||||
<P>See also <A href="#stdcall">"__stdcall" and "pascal" Support</A>.</P>
|
<P>See also <A href="#stdcall">"__stdcall" and "pascal" Support</A>.</P>
|
||||||
<h3><a name="err_overloaded">Binding an overloaded function</a></h3>
|
|
||||||
<p>An attempt to bind an overloaded function usually results in an error, as there
|
|
||||||
is no way to tell which overload was meant to be bound. This is a common
|
|
||||||
problem with member functions with two overloads, const and non-const, as in
|
|
||||||
this simplified example:</p>
|
|
||||||
<pre>struct X
|
|
||||||
{
|
|
||||||
int& get();
|
|
||||||
int const& get() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
boost::bind( &X::get, _1 );
|
|
||||||
}
|
|
||||||
</pre>
|
|
||||||
<P>The ambiguity can be resolved manually by casting the (member) function pointer
|
|
||||||
to the desired type:</P>
|
|
||||||
<pre>int main()
|
|
||||||
{
|
|
||||||
boost::bind( static_cast< int const& (X::*) () const >( &X::get ), _1 );
|
|
||||||
}
|
|
||||||
</pre>
|
|
||||||
<P>Another, arguably more readable, alternative is to introduce a temporary
|
|
||||||
variable:</P>
|
|
||||||
<pre>int main()
|
|
||||||
{
|
|
||||||
int const& (X::*get) () const = &X::get;
|
|
||||||
boost::bind( get, _1 );
|
|
||||||
}
|
|
||||||
</pre>
|
|
||||||
<h3><a name="err_const_arg"><b>const</b> in signatures</a></h3>
|
<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
|
<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:
|
top-level <b>const</b> in function signatures:
|
||||||
</p>
|
</p>
|
||||||
<pre>int f(int const);
|
<pre>int f(int const);
|
||||||
@@ -599,27 +543,27 @@ int main()
|
|||||||
<p>Workaround: remove the <b>const</b> qualifier from the argument.
|
<p>Workaround: remove the <b>const</b> qualifier from the argument.
|
||||||
</p>
|
</p>
|
||||||
<h3><a name="err_msvc_using">MSVC specific: using boost::bind;</a></h3>
|
<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
|
<p>On MSVC (up to version 7.0), when <b>boost::bind</b> is brought into scope with
|
||||||
an using declaration:
|
an using declaration:
|
||||||
</p>
|
</p>
|
||||||
<pre>using boost::bind;
|
<pre>using boost::bind;
|
||||||
</pre>
|
</pre>
|
||||||
<p>the syntax <tt>bind<R>(f, ...)</tt> does not work. Workaround: either use
|
<p>the syntax <tt>bind<R>(f, ...)</tt> does not work. Workaround: either use
|
||||||
the qualified name, <b>boost::bind</b>, or use an using directive instead:
|
the qualified name, <b>boost::bind</b>, or use an using directive instead:
|
||||||
</p>
|
</p>
|
||||||
<pre>using namespace boost;
|
<pre>using namespace boost;
|
||||||
</pre>
|
</pre>
|
||||||
<h3><a name="err_msvc_class_template">MSVC specific: class templates shadow function
|
<h3><a name="err_msvc_class_template">MSVC specific: class templates shadow function
|
||||||
templates</a></h3>
|
templates</a></h3>
|
||||||
<p>On MSVC (up to version 7.0), a nested class template named <b>bind</b> will
|
<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 <tt>bind<R>(f,
|
shadow the function template <b>boost::bind</b>, breaking the <tt>bind<R>(f,
|
||||||
...)</tt> syntax. Unfortunately, some libraries contain nested class
|
...)</tt> syntax. Unfortunately, some libraries contain nested class
|
||||||
templates named <b>bind</b> (ironically, such code is often an MSVC specific
|
templates named <b>bind</b> (ironically, such code is often an MSVC specific
|
||||||
workaround.)</p>
|
workaround.)</p>
|
||||||
<P>The workaround is to use the alternative <tt>bind(type<R>(), f, ...)</tt> syntax.</P>
|
<P>The workaround is to use the alternative <tt>bind(type<R>(), f, ...)</tt> syntax.</P>
|
||||||
<h3><a name="err_msvc_ellipsis">MSVC specific: ... in signatures treated as type</a></h3>
|
<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
|
<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
|
(such as <b>std::printf</b>) as a type. Therefore, it will accept the
|
||||||
(incorrect in the current implementation) form:
|
(incorrect in the current implementation) form:
|
||||||
</p>
|
</p>
|
||||||
<pre> bind(printf, "%s\n", _1);
|
<pre> bind(printf, "%s\n", _1);
|
||||||
@@ -687,10 +631,10 @@ namespace
|
|||||||
<h3><a name="CommonRequirements">Common requirements</a></h3>
|
<h3><a name="CommonRequirements">Common requirements</a></h3>
|
||||||
<p>All <tt><i>unspecified-N</i></tt> types returned by <b>bind</b> are <b>CopyConstructible</b>.
|
<p>All <tt><i>unspecified-N</i></tt> types returned by <b>bind</b> are <b>CopyConstructible</b>.
|
||||||
<tt><i>unspecified-N</i>::result_type</tt> is defined as the return type of <tt><i>unspecified-N</i>::operator()</tt>.</p>
|
<tt><i>unspecified-N</i>::result_type</tt> is defined as the return type of <tt><i>unspecified-N</i>::operator()</tt>.</p>
|
||||||
<p>All <tt><i>unspecified-placeholder-N</i></tt> types are <b>CopyConstructible</b>.
|
<p>All <tt><i>unspecified-placeholder-N</i></tt> types are <b>CopyConstructible</b>.
|
||||||
Their copy constructors do not throw exceptions.</p>
|
Their copy constructors do not throw exceptions.</p>
|
||||||
<h3><a name="CommonDefinitions">Common definitions</a></h3>
|
<h3><a name="CommonDefinitions">Common definitions</a></h3>
|
||||||
<p>The function µ(x, v<sub>1</sub>, v<sub>2</sub>, ..., v<sub>m</sub>), where m is
|
<p>The function µ(x, v<sub>1</sub>, v<sub>2</sub>, ..., v<sub>m</sub>), where m is
|
||||||
a nonnegative integer, is defined as:</p>
|
a nonnegative integer, is defined as:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
@@ -700,81 +644,81 @@ namespace
|
|||||||
v<sub>k</sub>, when <tt>x</tt>
|
v<sub>k</sub>, when <tt>x</tt>
|
||||||
is (a copy of) the placeholder _k for some positive integer k;
|
is (a copy of) the placeholder _k for some positive integer k;
|
||||||
<li>
|
<li>
|
||||||
<tt>x(v<sub>1</sub>, v<sub>2</sub>, ..., v<sub>m</sub>)</tt> when <tt>x</tt> is
|
<tt>x(v<sub>1</sub>, v<sub>2</sub>, ..., v<sub>m</sub>)</tt> when <tt>x</tt> is
|
||||||
(a copy of) a function object returned by <b>bind</b>;
|
(a copy of) a function object returned by <b>bind</b>;
|
||||||
<li>
|
<li>
|
||||||
<tt>x</tt> otherwise.</li></ul>
|
<tt>x</tt> otherwise.</li></ul>
|
||||||
<h3><a name="bind">bind</a></h3>
|
<h3><a name="bind">bind</a></h3>
|
||||||
<h4><a name="bind_1">template<class R, class F> <i>unspecified-1</i> bind(F f)</a></h4>
|
<h4><a name="bind_1">template<class R, class F> <i>unspecified-1</i> bind(F f)</a></h4>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Returns:</b> A function object <i>λ</i> such that the expression <tt>λ(v<sub>1</sub>,
|
<p><b>Returns:</b> A function object <i>λ</i> such that the expression <tt>λ(v<sub>1</sub>,
|
||||||
v<sub>2</sub>, ..., v<sub>m</sub>)</tt> is equivalent to <tt><b>f</b>()</tt>,
|
v<sub>2</sub>, ..., v<sub>m</sub>)</tt> is equivalent to <tt><b>f</b>()</tt>,
|
||||||
implicitly converted to <b>R</b>.</p>
|
implicitly converted to <b>R</b>.</p>
|
||||||
<p><b>Throws:</b> Nothing unless the copy constructor of <b>F</b> throws an
|
<p><b>Throws:</b> Nothing unless the copy constructor of <b>F</b> throws an
|
||||||
exception.</p>
|
exception.</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<h4><a name="bind_1_1">template<class F> <i>unspecified-1-1</i> bind(F f)</a></h4>
|
<h4><a name="bind_1_1">template<class F> <i>unspecified-1-1</i> bind(F f)</a></h4>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Effects:</b> Equivalent to <tt>bind<typename F::result_type, F>(f);</tt></p>
|
<p><b>Effects:</b> Equivalent to <tt>bind<typename F::result_type, F>(f);</tt></p>
|
||||||
<p><b>Notes:</b> Implementations are allowed to infer the return type of <b>f</b> via
|
<p><b>Notes:</b> Implementations are allowed to infer the return type of <b>f</b> via
|
||||||
other means as an extension, without relying on the <tt>result_type</tt> member.</p>
|
other means as an extension, without relying on the <tt>result_type</tt> member.</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<h4><a name="bind_2">template<class R> <i>unspecified-2</i> bind(R (*f) ())</a></h4>
|
<h4><a name="bind_2">template<class R> <i>unspecified-2</i> bind(R (*f) ())</a></h4>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Returns:</b> A function object <i>λ</i> such that the expression <tt>λ(v<sub>1</sub>,
|
<p><b>Returns:</b> A function object <i>λ</i> such that the expression <tt>λ(v<sub>1</sub>,
|
||||||
v<sub>2</sub>, ..., v<sub>m</sub>)</tt> is equivalent to <tt><b>f</b>()</tt>.</p>
|
v<sub>2</sub>, ..., v<sub>m</sub>)</tt> is equivalent to <tt><b>f</b>()</tt>.</p>
|
||||||
<p><b>Throws:</b> Nothing.</p>
|
<p><b>Throws:</b> Nothing.</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<h4><a name="bind_3">template<class R, class F, class A1> <i>unspecified-3</i> bind(F
|
<h4><a name="bind_3">template<class R, class F, class A1> <i>unspecified-3</i> bind(F
|
||||||
f, A1 a1)</a></h4>
|
f, A1 a1)</a></h4>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Returns:</b> A function object <i>λ</i> such that the expression <tt>λ(v<sub>1</sub>,
|
<p><b>Returns:</b> A function object <i>λ</i> such that the expression <tt>λ(v<sub>1</sub>,
|
||||||
v<sub>2</sub>, ..., v<sub>m</sub>)</tt> is equivalent to <tt><b>f</b>(µ(<b>a1</b>,
|
v<sub>2</sub>, ..., v<sub>m</sub>)</tt> is equivalent to <tt><b>f</b>(µ(<b>a1</b>,
|
||||||
v<sub>1</sub>, v<sub>2</sub>, ..., v<sub>m</sub>))</tt>, implicitly
|
v<sub>1</sub>, v<sub>2</sub>, ..., v<sub>m</sub>))</tt>, implicitly
|
||||||
converted to <b>R</b>.</p>
|
converted to <b>R</b>.</p>
|
||||||
<p><b>Throws:</b> Nothing unless the copy constructors of <b>F</b> or <b>A1</b> throw
|
<p><b>Throws:</b> Nothing unless the copy constructors of <b>F</b> or <b>A1</b> throw
|
||||||
an exception.</p>
|
an exception.</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<h4><a name="bind_3_1">template<class F, class A1> <i>unspecified-3-1</i> bind(F
|
<h4><a name="bind_3_1">template<class F, class A1> <i>unspecified-3-1</i> bind(F
|
||||||
f, A1 a1)</a></h4>
|
f, A1 a1)</a></h4>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Effects:</b> Equivalent to <tt>bind<typename F::result_type, F, A1>(f, a1);</tt></p>
|
<p><b>Effects:</b> Equivalent to <tt>bind<typename F::result_type, F, A1>(f, a1);</tt></p>
|
||||||
<p><b>Notes:</b> Implementations are allowed to infer the return type of <b>f</b> via
|
<p><b>Notes:</b> Implementations are allowed to infer the return type of <b>f</b> via
|
||||||
other means as an extension, without relying on the <tt>result_type</tt> member.</p>
|
other means as an extension, without relying on the <tt>result_type</tt> member.</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<h4><a name="bind_4">template<class R, class B1, class A1> <i>unspecified-4</i> bind(R
|
<h4><a name="bind_4">template<class R, class B1, class A1> <i>unspecified-4</i> bind(R
|
||||||
(*f) (B1), A1 a1)</a></h4>
|
(*f) (B1), A1 a1)</a></h4>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Returns:</b> A function object <i>λ</i> such that the expression <tt>λ(v<sub>1</sub>,
|
<p><b>Returns:</b> A function object <i>λ</i> such that the expression <tt>λ(v<sub>1</sub>,
|
||||||
v<sub>2</sub>, ..., v<sub>m</sub>)</tt> is equivalent to <tt><b>f</b>(µ(<b>a1</b>,
|
v<sub>2</sub>, ..., v<sub>m</sub>)</tt> is equivalent to <tt><b>f</b>(µ(<b>a1</b>,
|
||||||
v<sub>1</sub>, v<sub>2</sub>, ..., v<sub>m</sub>))</tt>.</p>
|
v<sub>1</sub>, v<sub>2</sub>, ..., v<sub>m</sub>))</tt>.</p>
|
||||||
<p><b>Throws:</b> Nothing unless the copy constructor of <b>A1</b> throws an
|
<p><b>Throws:</b> Nothing unless the copy constructor of <b>A1</b> throws an
|
||||||
exception.</p>
|
exception.</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<h4><a name="bind_5">template<class R, class T, class A1> <i>unspecified-5</i> bind(R
|
<h4><a name="bind_5">template<class R, class T, class A1> <i>unspecified-5</i> bind(R
|
||||||
(T::*f) (), A1 a1)</a></h4>
|
(T::*f) (), A1 a1)</a></h4>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Effects:</b> Equivalent to <tt>bind<R>(<A href="mem_fn.html">boost::mem_fn</A>(f),
|
<p><b>Effects:</b> Equivalent to <tt>bind<R>(<A href="mem_fn.html">boost::mem_fn</A>(f),
|
||||||
a1);</tt></p>
|
a1);</tt></p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<h4><a name="bind_6">template<class R, class T, class A1> <i>unspecified-6</i> bind(R
|
<h4><a name="bind_6">template<class R, class T, class A1> <i>unspecified-6</i> bind(R
|
||||||
(T::*f) () const, A1 a1)</a></h4>
|
(T::*f) () const, A1 a1)</a></h4>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Effects:</b> Equivalent to <tt>bind<R>(<A href="mem_fn.html">boost::mem_fn</A>(f),
|
<p><b>Effects:</b> Equivalent to <tt>bind<R>(<A href="mem_fn.html">boost::mem_fn</A>(f),
|
||||||
a1);</tt></p>
|
a1);</tt></p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<h4><a name="bind_6_1">template<class R, class T, class A1> <i>unspecified-6-1</i>
|
<h4><a name="bind_6_1">template<class R, class T, class A1> <i>unspecified-6-1</i>
|
||||||
bind(R T::*f, A1 a1)</a></h4>
|
bind(R T::*f, A1 a1)</a></h4>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Effects:</b> Equivalent to <tt>bind<R>(<A href="mem_fn.html">boost::mem_fn</A>(f),
|
<p><b>Effects:</b> Equivalent to <tt>bind<R>(<A href="mem_fn.html">boost::mem_fn</A>(f),
|
||||||
a1);</tt></p>
|
a1);</tt></p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<h4><a name="bind_7">template<class R, class F, class A1, class A2> <i>unspecified-7</i>
|
<h4><a name="bind_7">template<class R, class F, class A1, class A2> <i>unspecified-7</i>
|
||||||
bind(F f, A1 a1, A2 a2)</a></h4>
|
bind(F f, A1 a1, A2 a2)</a></h4>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Returns:</b> A function object <i>λ</i> such that the expression <tt>λ(v<sub>1</sub>,
|
<p><b>Returns:</b> A function object <i>λ</i> such that the expression <tt>λ(v<sub>1</sub>,
|
||||||
v<sub>2</sub>, ..., v<sub>m</sub>)</tt> is equivalent to <tt><b>f</b>(µ(<b>a1</b>,
|
v<sub>2</sub>, ..., v<sub>m</sub>)</tt> is equivalent to <tt><b>f</b>(µ(<b>a1</b>,
|
||||||
v<sub>1</sub>, v<sub>2</sub>, ..., v<sub>m</sub>), µ(<b>a2</b>, v<sub>1</sub>,
|
v<sub>1</sub>, v<sub>2</sub>, ..., v<sub>m</sub>), µ(<b>a2</b>, v<sub>1</sub>,
|
||||||
v<sub>2</sub>, ..., v<sub>m</sub>))</tt>, implicitly converted to <b>R</b>.</p>
|
v<sub>2</sub>, ..., v<sub>m</sub>))</tt>, implicitly converted to <b>R</b>.</p>
|
||||||
<p><b>Throws:</b> Nothing unless the copy constructors of <b>F</b>, <b>A1</b> or <b>A2</b>
|
<p><b>Throws:</b> Nothing unless the copy constructors of <b>F</b>, <b>A1</b> or <b>A2</b>
|
||||||
throw an exception.</p>
|
throw an exception.</p>
|
||||||
@@ -782,35 +726,35 @@ namespace
|
|||||||
<h4><a name="bind_7_1">template<class F, class A1, class A2> <i>unspecified-7-1</i>
|
<h4><a name="bind_7_1">template<class F, class A1, class A2> <i>unspecified-7-1</i>
|
||||||
bind(F f, A1 a1, A2 a2)</a></h4>
|
bind(F f, A1 a1, A2 a2)</a></h4>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Effects:</b> Equivalent to <tt>bind<typename F::result_type, F, A1, A2>(f,
|
<p><b>Effects:</b> Equivalent to <tt>bind<typename F::result_type, F, A1, A2>(f,
|
||||||
a1, a2);</tt></p>
|
a1, a2);</tt></p>
|
||||||
<p><b>Notes:</b> Implementations are allowed to infer the return type of <b>f</b> via
|
<p><b>Notes:</b> Implementations are allowed to infer the return type of <b>f</b> via
|
||||||
other means as an extension, without relying on the <tt>result_type</tt> member.</p>
|
other means as an extension, without relying on the <tt>result_type</tt> member.</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<h4><a name="bind_8">template<class R, class B1, class B2, class A1, class A2> <i>unspecified-8</i>
|
<h4><a name="bind_8">template<class R, class B1, class B2, class A1, class A2> <i>unspecified-8</i>
|
||||||
bind(R (*f) (B1, B2), A1 a1, A2 a2)</a></h4>
|
bind(R (*f) (B1, B2), A1 a1, A2 a2)</a></h4>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Returns:</b> A function object <i>λ</i> such that the expression <tt>λ(v<sub>1</sub>,
|
<p><b>Returns:</b> A function object <i>λ</i> such that the expression <tt>λ(v<sub>1</sub>,
|
||||||
v<sub>2</sub>, ..., v<sub>m</sub>)</tt> is equivalent to <tt><b>f</b>(µ(<b>a1</b>,
|
v<sub>2</sub>, ..., v<sub>m</sub>)</tt> is equivalent to <tt><b>f</b>(µ(<b>a1</b>,
|
||||||
v<sub>1</sub>, v<sub>2</sub>, ..., v<sub>m</sub>), µ(<b>a2</b>, v<sub>1</sub>,
|
v<sub>1</sub>, v<sub>2</sub>, ..., v<sub>m</sub>), µ(<b>a2</b>, v<sub>1</sub>,
|
||||||
v<sub>2</sub>, ..., v<sub>m</sub>))</tt>.</p>
|
v<sub>2</sub>, ..., v<sub>m</sub>))</tt>.</p>
|
||||||
<p><b>Throws:</b> Nothing unless the copy constructors of <b>A1</b> or <b>A2</b> throw
|
<p><b>Throws:</b> Nothing unless the copy constructors of <b>A1</b> or <b>A2</b> throw
|
||||||
an exception.</p>
|
an exception.</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<h4><a name="bind_9">template<class R, class T, class B1, class A1, class A2> <i>unspecified-9</i>
|
<h4><a name="bind_9">template<class R, class T, class B1, class A1, class A2> <i>unspecified-9</i>
|
||||||
bind(R (T::*f) (B1), A1 a1, A2 a2)</a></h4>
|
bind(R (T::*f) (B1), A1 a1, A2 a2)</a></h4>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Effects:</b> Equivalent to <tt>bind<R>(<A href="mem_fn.html">boost::mem_fn</A>(f),
|
<p><b>Effects:</b> Equivalent to <tt>bind<R>(<A href="mem_fn.html">boost::mem_fn</A>(f),
|
||||||
a1, a2);</tt></p>
|
a1, a2);</tt></p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<h4><a name="bind_10">template<class R, class T, class B1, class A1, class A2> <i>unspecified-10</i>
|
<h4><a name="bind_10">template<class R, class T, class B1, class A1, class A2> <i>unspecified-10</i>
|
||||||
bind(R (T::*f) (B1) const, A1 a1, A2 a2)</a></h4>
|
bind(R (T::*f) (B1) const, A1 a1, A2 a2)</a></h4>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Effects:</b> Equivalent to <tt>bind<R>(<A href="mem_fn.html">boost::mem_fn</A>(f),
|
<p><b>Effects:</b> Equivalent to <tt>bind<R>(<A href="mem_fn.html">boost::mem_fn</A>(f),
|
||||||
a1, a2);</tt></p>
|
a1, a2);</tt></p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<h3><a name="AdditionalOverloads">Additional overloads</a></h3>
|
<h3><a name="AdditionalOverloads">Additional overloads</a></h3>
|
||||||
<p>Implementations are allowed to provide additional <b>bind</b> overloads in order
|
<p>Implementations are allowed to provide additional <b>bind</b> overloads in order
|
||||||
to support more arguments or different function pointer variations.</p>
|
to support more arguments or different function pointer variations.</p>
|
||||||
<h2><a name="Implementation">Implementation</a></h2>
|
<h2><a name="Implementation">Implementation</a></h2>
|
||||||
<h3><a name="Files">Files</a></h3>
|
<h3><a name="Files">Files</a></h3>
|
||||||
@@ -840,7 +784,7 @@ namespace
|
|||||||
<A href="../../boost/bind/protect.hpp">boost/bind/protect.hpp</A> (<STRONG>protect</STRONG>
|
<A href="../../boost/bind/protect.hpp">boost/bind/protect.hpp</A> (<STRONG>protect</STRONG>
|
||||||
helper function)
|
helper function)
|
||||||
<LI>
|
<LI>
|
||||||
<A href="../../boost/bind/make_adaptable.hpp">boost/bind/make_adaptable.hpp</A>
|
<A href="../../boost/bind/make_adaptable.hpp">boost/bind/make_adaptable.hpp</A>
|
||||||
(<STRONG>make_adaptable</STRONG>
|
(<STRONG>make_adaptable</STRONG>
|
||||||
helper function)
|
helper function)
|
||||||
<li>
|
<li>
|
||||||
@@ -876,19 +820,19 @@ namespace
|
|||||||
<A href="../../boost/type.hpp">boost/type.hpp</A></li>
|
<A href="../../boost/type.hpp">boost/type.hpp</A></li>
|
||||||
</ul>
|
</ul>
|
||||||
<h3><a name="NumberOfArguments">Number of Arguments</a></h3>
|
<h3><a name="NumberOfArguments">Number of Arguments</a></h3>
|
||||||
<p>This implementation supports function objects with up to nine arguments. This is
|
<p>This implementation supports function objects with up to nine arguments. This is
|
||||||
an implementation detail, not an inherent limitation of the design.</p>
|
an implementation detail, not an inherent limitation of the design.</p>
|
||||||
<h3><a name="stdcall">"__stdcall", "__cdecl", "__fastcall", and "pascal" Support</a></h3>
|
<h3><a name="stdcall">"__stdcall", "__cdecl", "__fastcall", and "pascal" Support</a></h3>
|
||||||
<p>Some platforms allow several types of (member) functions that differ by their <b>calling
|
<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
|
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
|
arguments passed, how is the return value handled, and who cleans up the stack
|
||||||
- if any.)</p>
|
- if any.)</p>
|
||||||
<p>For example, Windows API functions and COM interface member functions use a
|
<p>For example, Windows API functions and COM interface member functions use a
|
||||||
calling convention known as <b>__stdcall</b>.Borland VCL components use <STRONG>__fastcall</STRONG>.
|
calling convention known as <b>__stdcall</b>.Borland VCL components use <STRONG>__fastcall</STRONG>.
|
||||||
Mac toolbox functions use a <b>pascal</b> calling convention.</p>
|
Mac toolbox functions use a <b>pascal</b> calling convention.</p>
|
||||||
<p>To use <b>bind</b> with <b>__stdcall</b> functions, <b>#define</b> the macro <b>BOOST_BIND_ENABLE_STDCALL</b>
|
<p>To use <b>bind</b> with <b>__stdcall</b> functions, <b>#define</b> the macro <b>BOOST_BIND_ENABLE_STDCALL</b>
|
||||||
before including <b><boost/bind.hpp></b>.</p>
|
before including <b><boost/bind.hpp></b>.</p>
|
||||||
<p>To use <b>bind</b> with <b>__stdcall</b> <b>member</b> functions, <b>#define</b>
|
<p>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><boost/bind.hpp></b>.</p>
|
the macro <b>BOOST_MEM_FN_ENABLE_STDCALL</b> before including <b><boost/bind.hpp></b>.</p>
|
||||||
<P>To use <B>bind</B> with <B>__fastcall</B> functions, <B>#define</B> the macro <B>BOOST_BIND_ENABLE_FASTCALL</B>
|
<P>To use <B>bind</B> with <B>__fastcall</B> functions, <B>#define</B> the macro <B>BOOST_BIND_ENABLE_FASTCALL</B>
|
||||||
before including <B><boost/bind.hpp></B>.</P>
|
before including <B><boost/bind.hpp></B>.</P>
|
||||||
@@ -896,16 +840,16 @@ namespace
|
|||||||
the macro <B>BOOST_MEM_FN_ENABLE_FASTCALL</B> before including <B><boost/bind.hpp></B>.</P>
|
the macro <B>BOOST_MEM_FN_ENABLE_FASTCALL</B> before including <B><boost/bind.hpp></B>.</P>
|
||||||
<P>To use <b>bind</b> with <b>pascal</b> functions, <b>#define</b> the macro <b>BOOST_BIND_ENABLE_PASCAL</b>
|
<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><boost/bind.hpp></b>.</P>
|
before including <b><boost/bind.hpp></b>.</P>
|
||||||
<P>To use <B>bind</B> with <B>__cdecl</B> <B>member</B> functions, <B>#define</B> the
|
<P>To use <B>bind</B> with <B>__cdecl</B> <B>member</B> functions, <B>#define</B> the
|
||||||
macro <B>BOOST_MEM_FN_ENABLE_CDECL</B> before including <B><boost/bind.hpp></B>.</P>
|
macro <B>BOOST_MEM_FN_ENABLE_CDECL</B> before including <B><boost/bind.hpp></B>.</P>
|
||||||
<P><STRONG>It is best to define these macros in the project options, via -D on the
|
<P><STRONG>It is best to define these macros in the project options, via -D on the
|
||||||
command line, or as the first line in the translation unit (.cpp file) where
|
command line, or as the first line in the translation unit (.cpp file) where
|
||||||
bind is used.</STRONG> Not following this rule can lead to obscure errors
|
bind is used.</STRONG> Not following this rule can lead to obscure errors
|
||||||
when a header includes bind.hpp before the macro has been defined.</P>
|
when a header includes bind.hpp before the macro has been defined.</P>
|
||||||
<p>[Note: this is a non-portable extension. It is not part of the interface.]</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>
|
<p>[Note: Some compilers provide only minimal support for the <b>__stdcall</b> keyword.]</p>
|
||||||
<h3><a name="visit_each"><b>visit_each</b> support</a></h3>
|
<h3><a name="visit_each"><b>visit_each</b> support</a></h3>
|
||||||
<p>Function objects returned by <b>bind</b> support the experimental and
|
<p>Function objects returned by <b>bind</b> support the experimental and
|
||||||
undocumented, as of yet, <b>visit_each</b> enumeration interface.</p>
|
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>
|
<p>See <A href="bind_visitor.cpp">bind_visitor.cpp</A> for an example.</p>
|
||||||
<h2><a name="Acknowledgements">Acknowledgements</a></h2>
|
<h2><a name="Acknowledgements">Acknowledgements</a></h2>
|
||||||
@@ -915,40 +859,41 @@ namespace
|
|||||||
The <a href="http://staff.cs.utu.fi/BL/">Binder Library</a>
|
The <a href="http://staff.cs.utu.fi/BL/">Binder Library</a>
|
||||||
by Jaakko Järvi;
|
by Jaakko Järvi;
|
||||||
<li>
|
<li>
|
||||||
The <a href="../lambda/index.html">Lambda Library</a>
|
The <a href="../lambda/">Lambda Library</a>
|
||||||
(now part of Boost) by Jaakko Järvi and Gary Powell (the successor to the
|
(now part of Boost) by Jaakko Järvi and Gary Powell (the successor to the
|
||||||
Binder Library);
|
Binder Library);
|
||||||
<li>
|
<li>
|
||||||
<a href="http://more.sourceforge.net/">Extensions to the STL</a> by Petter
|
<a href="http://more.sourceforge.net/">Extensions to the
|
||||||
Urkedal.</li></ul>
|
STL</a> by Petter Urkedal.</li></ul>
|
||||||
<p>Doug Gregor suggested that a visitor mechanism would allow <b>bind</b> to
|
<p>Doug Gregor suggested that a visitor mechanism would allow <b>bind</b> to
|
||||||
interoperate with a signal/slot library.</p>
|
interoperate with a signal/slot library.</p>
|
||||||
<p>John Maddock fixed a MSVC-specific conflict between <b>bind</b> and the <A href="../type_traits/index.html">
|
<p>John Maddock fixed a MSVC-specific conflict between <b>bind</b> and the <A href="../type_traits/index.html">
|
||||||
type traits library</A>.</p>
|
type traits library</A>.</p>
|
||||||
<p>Numerous improvements were suggested during the formal review period by Ross
|
<p>Numerous improvements were suggested during the formal review period by Ross
|
||||||
Smith, Richard Crossley, Jens Maurer, Ed Brey, and others. Review manager was
|
Smith, Richard Crossley, Jens Maurer, Ed Brey, and others. Review manager was
|
||||||
Darin Adler.
|
Darin Adler.
|
||||||
</p>
|
</p>
|
||||||
<p>The precise semantics of <b>bind</b> were refined in discussions with Jaakko
|
<p>The precise semantics of <b>bind</b> were refined in discussions with Jaakko
|
||||||
Järvi.
|
Järvi.
|
||||||
</p>
|
</p>
|
||||||
<p>Dave Abrahams fixed a MSVC-specific conflict between <b>bind</b> and the <A href="../utility/iterator_adaptors.htm">
|
<p>Dave Abrahams fixed a MSVC-specific conflict between <b>bind</b> and the <A href="../utility/iterator_adaptors.htm">
|
||||||
iterator adaptors library</A>.
|
iterator adaptors library</A>.
|
||||||
</p>
|
</p>
|
||||||
<p>Dave Abrahams modified <b>bind</b> and <b>mem_fn</b> to support void returns on
|
<p>Dave Abrahams modified <b>bind</b> and <b>mem_fn</b> to support void returns on
|
||||||
deficient compilers.
|
deficient compilers.
|
||||||
</p>
|
</p>
|
||||||
<p>Mac Murrett contributed the "pascal" support enabled by
|
<p>Mac Murrett contributed the "pascal" support enabled by
|
||||||
BOOST_BIND_ENABLE_PASCAL.
|
BOOST_BIND_ENABLE_PASCAL.
|
||||||
</p>
|
</p>
|
||||||
<p>The alternative <tt>bind(type<R>(), f, ...)</tt> syntax was inspired by a
|
<p>The alternative <tt>bind(type<R>(), f, ...)</tt> syntax was inspired by a
|
||||||
discussion with Dave Abrahams and Joel de Guzman.</p>
|
discussion with Dave Abrahams and Joel de Guzman.</p>
|
||||||
<p><br>
|
<p><br>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<small>Copyright © 2001, 2002 by Peter Dimov and Multi Media Ltd. Copyright
|
<small>Copyright © 2001, 2002 by Peter Dimov and Multi Media Ltd. Copyright
|
||||||
2003-2008 Peter Dimov. Distributed under the Boost Software License, Version
|
2003-2005 Peter Dimov. Permission to copy, use, modify, sell and distribute
|
||||||
1.0. See accompanying file <A href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</A> or
|
this document is granted provided this copyright notice appears in all copies.
|
||||||
copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>.</small></p>
|
This document is provided "as is" without express or implied warranty, and with
|
||||||
|
no claim as to its suitability for any purpose.</small></p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -31,18 +31,32 @@
|
|||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#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 visitor
|
struct visitor
|
||||||
{
|
{
|
||||||
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";
|
std::cout << "Reference to " << typeid(T).name() << " @ " << &r.get() << " (with value " << r.get() << ")\n";
|
||||||
|
hash += r.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T> void operator()( T const & t ) const
|
template<class T> void operator()(T const &, long) const
|
||||||
{
|
{
|
||||||
std::cout << "Value of type " << typeid(T).name() << " (with value " << t << ")\n";
|
std::cout << "Value of type " << typeid(T).name() << '\n';
|
||||||
|
++hash;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -56,10 +70,26 @@ int f(int & i, int & j, int)
|
|||||||
int x = 2;
|
int x = 2;
|
||||||
int y = 7;
|
int y = 7;
|
||||||
|
|
||||||
|
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()
|
int main()
|
||||||
{
|
{
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
|
|
||||||
visitor v;
|
visitor v;
|
||||||
visit_each(v, bind<int>(bind(f, ref(x), _1, 42), ref(y)), 0);
|
visit_each(v, bind<int>(bind(f, ref(x), _1, 42), ref(y)), 0);
|
||||||
|
|
||||||
|
return detect_errors(hash == 12);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,9 +38,11 @@
|
|||||||
</copyright>
|
</copyright>
|
||||||
|
|
||||||
<legalnotice>
|
<legalnotice>
|
||||||
<para>Subject to the Boost Software License, Version 1.0. See
|
<para>Permission to copy, use, modify, sell and distribute this
|
||||||
accompanying file <filename>LICENSE_1_0.txt</filename> or copy at
|
software is granted provided this copyright notice appears in
|
||||||
<ulink url="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</ulink>.
|
all copies. This software is provided "as is" without express
|
||||||
|
or implied warranty, and with no claim as to its suitability for
|
||||||
|
any purpose.
|
||||||
</para>
|
</para>
|
||||||
</legalnotice>
|
</legalnotice>
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -19,44 +19,18 @@
|
|||||||
// See http://www.boost.org/libs/bind/bind.html for documentation.
|
// See http://www.boost.org/libs/bind/bind.html for documentation.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
|
||||||
#include <boost/is_placeholder.hpp>
|
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
|
|
||||||
template< int I > struct arg
|
template<int I> class arg
|
||||||
{
|
{
|
||||||
arg()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
template< class T > arg( T const & /* t */ )
|
|
||||||
{
|
|
||||||
// static assert I == is_placeholder<T>::value
|
|
||||||
typedef char T_must_be_placeholder[ I == is_placeholder<T>::value? 1: -1 ];
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template< int I > bool operator==( arg<I> const &, arg<I> const & )
|
template<int I> bool operator==(arg<I> const &, arg<I> const &)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
|
|
||||||
|
|
||||||
template< int I > struct is_placeholder< arg<I> >
|
|
||||||
{
|
|
||||||
enum _vt { value = I };
|
|
||||||
};
|
|
||||||
|
|
||||||
template< int I > struct is_placeholder< arg<I> (*) () >
|
|
||||||
{
|
|
||||||
enum _vt { value = I };
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#endif // #ifndef BOOST_BIND_ARG_HPP_INCLUDED
|
#endif // #ifndef BOOST_BIND_ARG_HPP_INCLUDED
|
||||||
|
|||||||
@@ -1,228 +0,0 @@
|
|||||||
//
|
|
||||||
// bind/bind_mf2_cc.hpp - member functions, type<> syntax
|
|
||||||
//
|
|
||||||
// Do not include this header directly.
|
|
||||||
//
|
|
||||||
// Copyright (c) 2001 Peter Dimov and Multi Media Ltd.
|
|
||||||
// Copyright (c) 2008 Peter Dimov
|
|
||||||
//
|
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
|
||||||
// See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt
|
|
||||||
//
|
|
||||||
// See http://www.boost.org/libs/bind/bind.html for documentation.
|
|
||||||
//
|
|
||||||
|
|
||||||
// 0
|
|
||||||
|
|
||||||
template<class Rt2, class R, class T,
|
|
||||||
class A1>
|
|
||||||
_bi::bind_t<Rt2, _mfi::BOOST_BIND_MF_NAME(mf0)<R, T>, typename _bi::list_av_1<A1>::type>
|
|
||||||
BOOST_BIND(boost::type<Rt2>, 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<Rt2, F, list_type>(F(f), list_type(a1));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Rt2, class R, class T,
|
|
||||||
class A1>
|
|
||||||
_bi::bind_t<Rt2, _mfi::BOOST_BIND_MF_NAME(cmf0)<R, T>, typename _bi::list_av_1<A1>::type>
|
|
||||||
BOOST_BIND(boost::type<Rt2>, 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<Rt2, F, list_type>(F(f), list_type(a1));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1
|
|
||||||
|
|
||||||
template<class Rt2, class R, class T,
|
|
||||||
class B1,
|
|
||||||
class A1, class A2>
|
|
||||||
_bi::bind_t<Rt2, _mfi::BOOST_BIND_MF_NAME(mf1)<R, T, B1>, typename _bi::list_av_2<A1, A2>::type>
|
|
||||||
BOOST_BIND(boost::type<Rt2>, 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<Rt2, F, list_type>(F(f), list_type(a1, a2));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Rt2, class R, class T,
|
|
||||||
class B1,
|
|
||||||
class A1, class A2>
|
|
||||||
_bi::bind_t<Rt2, _mfi::BOOST_BIND_MF_NAME(cmf1)<R, T, B1>, typename _bi::list_av_2<A1, A2>::type>
|
|
||||||
BOOST_BIND(boost::type<Rt2>, 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<Rt2, F, list_type>(F(f), list_type(a1, a2));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2
|
|
||||||
|
|
||||||
template<class Rt2, class R, class T,
|
|
||||||
class B1, class B2,
|
|
||||||
class A1, class A2, class A3>
|
|
||||||
_bi::bind_t<Rt2, _mfi::BOOST_BIND_MF_NAME(mf2)<R, T, B1, B2>, typename _bi::list_av_3<A1, A2, A3>::type>
|
|
||||||
BOOST_BIND(boost::type<Rt2>, 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<Rt2, F, list_type>(F(f), list_type(a1, a2, a3));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Rt2, class R, class T,
|
|
||||||
class B1, class B2,
|
|
||||||
class A1, class A2, class A3>
|
|
||||||
_bi::bind_t<Rt2, _mfi::BOOST_BIND_MF_NAME(cmf2)<R, T, B1, B2>, typename _bi::list_av_3<A1, A2, A3>::type>
|
|
||||||
BOOST_BIND(boost::type<Rt2>, 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<Rt2, F, list_type>(F(f), list_type(a1, a2, a3));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3
|
|
||||||
|
|
||||||
template<class Rt2, class R, class T,
|
|
||||||
class B1, class B2, class B3,
|
|
||||||
class A1, class A2, class A3, class A4>
|
|
||||||
_bi::bind_t<Rt2, _mfi::BOOST_BIND_MF_NAME(mf3)<R, T, B1, B2, B3>, typename _bi::list_av_4<A1, A2, A3, A4>::type>
|
|
||||||
BOOST_BIND(boost::type<Rt2>, 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<Rt2, F, list_type>(F(f), list_type(a1, a2, a3, a4));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Rt2, class R, class T,
|
|
||||||
class B1, class B2, class B3,
|
|
||||||
class A1, class A2, class A3, class A4>
|
|
||||||
_bi::bind_t<Rt2, _mfi::BOOST_BIND_MF_NAME(cmf3)<R, T, B1, B2, B3>, typename _bi::list_av_4<A1, A2, A3, A4>::type>
|
|
||||||
BOOST_BIND(boost::type<Rt2>, 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<Rt2, F, list_type>(F(f), list_type(a1, a2, a3, a4));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4
|
|
||||||
|
|
||||||
template<class Rt2, 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<Rt2, _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(boost::type<Rt2>, 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<Rt2, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Rt2, 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<Rt2, _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(boost::type<Rt2>, 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<Rt2, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 5
|
|
||||||
|
|
||||||
template<class Rt2, 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<Rt2, _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(boost::type<Rt2>, 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<Rt2, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Rt2, 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<Rt2, _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(boost::type<Rt2>, 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<Rt2, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 6
|
|
||||||
|
|
||||||
template<class Rt2, 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<Rt2, _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(boost::type<Rt2>, 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<Rt2, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Rt2, 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<Rt2, _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(boost::type<Rt2>, 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<Rt2, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 7
|
|
||||||
|
|
||||||
template<class Rt2, 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<Rt2, _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(boost::type<Rt2>, 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<Rt2, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Rt2, 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<Rt2, _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(boost::type<Rt2>, 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<Rt2, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 8
|
|
||||||
|
|
||||||
template<class Rt2, 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<Rt2, _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(boost::type<Rt2>, 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<Rt2, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Rt2, 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<Rt2, _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(boost::type<Rt2>, 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<Rt2, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
|
|
||||||
}
|
|
||||||
@@ -38,23 +38,6 @@
|
|||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \
|
|
||||||
&& !BOOST_WORKAROUND(__EDG_VERSION__, <= 238)
|
|
||||||
|
|
||||||
template<class A1> result_type operator()(A1 const & a1)
|
|
||||||
{
|
|
||||||
list1<A1 const &> a(a1);
|
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class A1> result_type operator()(A1 const & a1) const
|
|
||||||
{
|
|
||||||
list1<A1 const &> a(a1);
|
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<class A1, class A2> result_type operator()(A1 & a1, A2 & a2)
|
template<class A1, class A2> result_type operator()(A1 & a1, A2 & a2)
|
||||||
{
|
{
|
||||||
list2<A1 &, A2 &> a(a1, a2);
|
list2<A1 &, A2 &> a(a1, a2);
|
||||||
@@ -67,49 +50,6 @@
|
|||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \
|
|
||||||
&& !BOOST_WORKAROUND(__EDG_VERSION__, <= 238)
|
|
||||||
|
|
||||||
template<class A1, class A2> result_type operator()(A1 const & a1, A2 & a2)
|
|
||||||
{
|
|
||||||
list2<A1 const &, A2 &> a(a1, a2);
|
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class A1, class A2> result_type operator()(A1 const & a1, A2 & a2) const
|
|
||||||
{
|
|
||||||
list2<A1 const &, A2 &> a(a1, a2);
|
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class A1, class A2> result_type operator()(A1 & a1, A2 const & a2)
|
|
||||||
{
|
|
||||||
list2<A1 &, A2 const &> a(a1, a2);
|
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class A1, class A2> result_type operator()(A1 & a1, A2 const & a2) const
|
|
||||||
{
|
|
||||||
list2<A1 &, A2 const &> a(a1, a2);
|
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class A1, class A2> result_type operator()(A1 const & a1, A2 const & a2)
|
|
||||||
{
|
|
||||||
list2<A1 const &, A2 const &> a(a1, a2);
|
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class A1, class A2> result_type operator()(A1 const & a1, A2 const & a2) const
|
|
||||||
{
|
|
||||||
list2<A1 const &, A2 const &> a(a1, a2);
|
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3> result_type operator()(A1 & a1, A2 & a2, A3 & a3)
|
template<class A1, class A2, class A3> result_type operator()(A1 & a1, A2 & a2, A3 & a3)
|
||||||
{
|
{
|
||||||
list3<A1 &, A2 &, A3 &> a(a1, a2, a3);
|
list3<A1 &, A2 &, A3 &> a(a1, a2, a3);
|
||||||
@@ -122,23 +62,6 @@
|
|||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \
|
|
||||||
&& !BOOST_WORKAROUND(__EDG_VERSION__, <= 238)
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3> result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3)
|
|
||||||
{
|
|
||||||
list3<A1 const &, A2 const &, A3 const &> a(a1, a2, a3);
|
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3> result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3) const
|
|
||||||
{
|
|
||||||
list3<A1 const &, A2 const &, A3 const &> a(a1, a2, a3);
|
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4)
|
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);
|
list4<A1 &, A2 &, A3 &, A4 &> a(a1, a2, a3, a4);
|
||||||
@@ -151,23 +74,6 @@
|
|||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \
|
|
||||||
&& !BOOST_WORKAROUND(__EDG_VERSION__, <= 238)
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4> result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4)
|
|
||||||
{
|
|
||||||
list4<A1 const &, A2 const &, A3 const &, A4 const &> a(a1, a2, a3, a4);
|
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4> result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4) const
|
|
||||||
{
|
|
||||||
list4<A1 const &, A2 const &, A3 const &, A4 const &> a(a1, a2, a3, a4);
|
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5)
|
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);
|
list5<A1 &, A2 &, A3 &, A4 &, A5 &> a(a1, a2, a3, a4, a5);
|
||||||
@@ -180,23 +86,6 @@
|
|||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \
|
|
||||||
&& !BOOST_WORKAROUND(__EDG_VERSION__, <= 238)
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5> result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5)
|
|
||||||
{
|
|
||||||
list5<A1 const &, A2 const &, A3 const &, A4 const &, A5 const &> a(a1, a2, a3, a4, a5);
|
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5> result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5) const
|
|
||||||
{
|
|
||||||
list5<A1 const &, A2 const &, A3 const &, A4 const &, A5 const &> a(a1, a2, a3, a4, a5);
|
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
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)
|
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);
|
list6<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &> a(a1, a2, a3, a4, a5, a6);
|
||||||
@@ -209,23 +98,6 @@
|
|||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \
|
|
||||||
&& !BOOST_WORKAROUND(__EDG_VERSION__, <= 238)
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5, class A6> result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6)
|
|
||||||
{
|
|
||||||
list6<A1 const &, A2 const &, A3 const &, A4 const &, A5 const &, A6 const &> a(a1, a2, a3, a4, a5, a6);
|
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5, class A6> result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6) const
|
|
||||||
{
|
|
||||||
list6<A1 const &, A2 const &, A3 const &, A4 const &, A5 const &, A6 const &> a(a1, a2, a3, a4, a5, a6);
|
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
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)
|
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);
|
list7<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &> a(a1, a2, a3, a4, a5, a6, a7);
|
||||||
@@ -238,23 +110,6 @@
|
|||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \
|
|
||||||
&& !BOOST_WORKAROUND(__EDG_VERSION__, <= 238)
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7)
|
|
||||||
{
|
|
||||||
list7<A1 const &, A2 const &, A3 const &, A4 const &, A5 const &, A6 const &, A7 const &> a(a1, a2, a3, a4, a5, a6, a7);
|
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7) const
|
|
||||||
{
|
|
||||||
list7<A1 const &, A2 const &, A3 const &, A4 const &, A5 const &, A6 const &, A7 const &> a(a1, a2, a3, a4, a5, a6, a7);
|
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
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)
|
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);
|
list8<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &, A8 &> a(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||||
@@ -267,23 +122,6 @@
|
|||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \
|
|
||||||
&& !BOOST_WORKAROUND(__EDG_VERSION__, <= 238)
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8)
|
|
||||||
{
|
|
||||||
list8<A1 const &, A2 const &, A3 const &, A4 const &, A5 const &, A6 const &, A7 const &, A8 const &> a(a1, a2, a3, a4, a5, a6, a7, a8);
|
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8) const
|
|
||||||
{
|
|
||||||
list8<A1 const &, A2 const &, A3 const &, A4 const &, A5 const &, A6 const &, A7 const &, A8 const &> a(a1, a2, a3, a4, a5, a6, a7, a8);
|
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
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)
|
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);
|
list9<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &, A8 &, A9 &> a(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||||
@@ -296,23 +134,6 @@
|
|||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \
|
|
||||||
&& !BOOST_WORKAROUND(__EDG_VERSION__, <= 238)
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8, A9 const & a9)
|
|
||||||
{
|
|
||||||
list9<A1 const &, A2 const &, A3 const &, A4 const &, A5 const &, A6 const &, A7 const &, A8 const &, A9 const &> a(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8, A9 const & a9) const
|
|
||||||
{
|
|
||||||
list9<A1 const &, A2 const &, A3 const &, A4 const &, A5 const &, A6 const &, A7 const &, A8 const &, A9 const &> a(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<class A> result_type eval(A & a)
|
template<class A> result_type eval(A & a)
|
||||||
{
|
{
|
||||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||||
@@ -325,11 +146,6 @@
|
|||||||
|
|
||||||
template<class V> void accept(V & v) const
|
template<class V> void accept(V & v) const
|
||||||
{
|
{
|
||||||
#if !defined( BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP ) && !defined( __BORLANDC__ )
|
|
||||||
|
|
||||||
using boost::visit_each;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
BOOST_BIND_VISIT_EACH(v, f_, 0);
|
BOOST_BIND_VISIT_EACH(v, f_, 0);
|
||||||
l_.accept(v);
|
l_.accept(v);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,6 @@
|
|||||||
// See http://www.boost.org/libs/bind/mem_fn.html for documentation.
|
// See http://www.boost.org/libs/bind/mem_fn.html for documentation.
|
||||||
//
|
//
|
||||||
|
|
||||||
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
|
|
||||||
# define BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// mf0
|
// mf0
|
||||||
|
|
||||||
template<class R, class T BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(mf0)
|
template<class R, class T BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(mf0)
|
||||||
@@ -54,15 +50,6 @@ public:
|
|||||||
BOOST_MEM_FN_RETURN call(u, &u);
|
BOOST_MEM_FN_RETURN call(u, &u);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
|
|
||||||
|
|
||||||
template<class U> R operator()(U const & u) const
|
|
||||||
{
|
|
||||||
BOOST_MEM_FN_RETURN call(u, &u);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
R operator()(T & t) const
|
R operator()(T & t) const
|
||||||
{
|
{
|
||||||
BOOST_MEM_FN_RETURN (t.*f_)();
|
BOOST_MEM_FN_RETURN (t.*f_)();
|
||||||
@@ -167,15 +154,6 @@ public:
|
|||||||
BOOST_MEM_FN_RETURN call(u, &u, a1);
|
BOOST_MEM_FN_RETURN call(u, &u, a1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
|
|
||||||
|
|
||||||
template<class U> R operator()(U const & u, A1 a1) const
|
|
||||||
{
|
|
||||||
BOOST_MEM_FN_RETURN call(u, &u, a1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
R operator()(T & t, A1 a1) const
|
R operator()(T & t, A1 a1) const
|
||||||
{
|
{
|
||||||
BOOST_MEM_FN_RETURN (t.*f_)(a1);
|
BOOST_MEM_FN_RETURN (t.*f_)(a1);
|
||||||
@@ -279,15 +257,6 @@ public:
|
|||||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2);
|
BOOST_MEM_FN_RETURN call(u, &u, a1, a2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
|
|
||||||
|
|
||||||
template<class U> R operator()(U const & u, A1 a1, A2 a2) const
|
|
||||||
{
|
|
||||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
R operator()(T & t, A1 a1, A2 a2) const
|
R operator()(T & t, A1 a1, A2 a2) const
|
||||||
{
|
{
|
||||||
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2);
|
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2);
|
||||||
@@ -389,15 +358,6 @@ public:
|
|||||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3);
|
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
R operator()(T & t, A1 a1, A2 a2, A3 a3) const
|
R operator()(T & t, A1 a1, A2 a2, A3 a3) const
|
||||||
{
|
{
|
||||||
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3);
|
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3);
|
||||||
@@ -499,15 +459,6 @@ public:
|
|||||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4);
|
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
R operator()(T & t, A1 a1, A2 a2, A3 a3, A4 a4) const
|
R operator()(T & t, A1 a1, A2 a2, A3 a3, A4 a4) const
|
||||||
{
|
{
|
||||||
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4);
|
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4);
|
||||||
@@ -609,15 +560,6 @@ public:
|
|||||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5);
|
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
R operator()(T & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
|
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);
|
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5);
|
||||||
@@ -719,15 +661,6 @@ public:
|
|||||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6);
|
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
R operator()(T & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
|
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);
|
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6);
|
||||||
@@ -829,15 +762,6 @@ public:
|
|||||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7);
|
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
R operator()(T & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
|
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);
|
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6, a7);
|
||||||
@@ -939,15 +863,6 @@ public:
|
|||||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7, a8);
|
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7, a8);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
R operator()(T & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
|
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);
|
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||||
@@ -1017,4 +932,3 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
#if defined(__BORLANDC__) || defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ <= 400)
|
#if defined(__BORLANDC__)
|
||||||
|
|
||||||
static inline boost::arg<1> _1() { return boost::arg<1>(); }
|
static inline boost::arg<1> _1() { return boost::arg<1>(); }
|
||||||
static inline boost::arg<2> _2() { return boost::arg<2>(); }
|
static inline boost::arg<2> _2() { return boost::arg<2>(); }
|
||||||
|
|||||||
@@ -1,475 +0,0 @@
|
|||||||
#ifndef BOOST_BIND_STORAGE_HPP_INCLUDED
|
|
||||||
#define BOOST_BIND_STORAGE_HPP_INCLUDED
|
|
||||||
|
|
||||||
// MS compatible compilers support #pragma once
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
|
||||||
# pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//
|
|
||||||
// bind/storage.hpp
|
|
||||||
//
|
|
||||||
// boost/bind.hpp support header, optimized storage
|
|
||||||
//
|
|
||||||
// Copyright (c) 2006 Peter Dimov
|
|
||||||
//
|
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
|
||||||
// See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt
|
|
||||||
//
|
|
||||||
// See http://www.boost.org/libs/bind/bind.html for documentation.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
|
||||||
#include <boost/bind/arg.hpp>
|
|
||||||
|
|
||||||
#ifdef BOOST_MSVC
|
|
||||||
# pragma warning(push)
|
|
||||||
# pragma warning(disable: 4512) // assignment operator could not be generated
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace boost
|
|
||||||
{
|
|
||||||
|
|
||||||
namespace _bi
|
|
||||||
{
|
|
||||||
|
|
||||||
// 1
|
|
||||||
|
|
||||||
template<class A1> struct storage1
|
|
||||||
{
|
|
||||||
explicit storage1( A1 a1 ): a1_( a1 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
BOOST_BIND_VISIT_EACH(v, a1_, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
A1 a1_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) && !defined( __BORLANDC__ )
|
|
||||||
|
|
||||||
template<int I> struct storage1< boost::arg<I> >
|
|
||||||
{
|
|
||||||
explicit storage1( boost::arg<I> ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V &) const { }
|
|
||||||
|
|
||||||
static boost::arg<I> a1_() { return boost::arg<I>(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<int I> struct storage1< boost::arg<I> (*) () >
|
|
||||||
{
|
|
||||||
explicit storage1( boost::arg<I> (*) () ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V &) const { }
|
|
||||||
|
|
||||||
static boost::arg<I> a1_() { return boost::arg<I>(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 2
|
|
||||||
|
|
||||||
template<class A1, class A2> struct storage2: public storage1<A1>
|
|
||||||
{
|
|
||||||
typedef storage1<A1> inherited;
|
|
||||||
|
|
||||||
storage2( A1 a1, A2 a2 ): storage1<A1>( a1 ), a2_( a2 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
BOOST_BIND_VISIT_EACH(v, a2_, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
A2 a2_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
|
|
||||||
|
|
||||||
template<class A1, int I> struct storage2< A1, boost::arg<I> >: public storage1<A1>
|
|
||||||
{
|
|
||||||
typedef storage1<A1> inherited;
|
|
||||||
|
|
||||||
storage2( A1 a1, boost::arg<I> ): storage1<A1>( a1 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
static boost::arg<I> a2_() { return boost::arg<I>(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class A1, int I> struct storage2< A1, boost::arg<I> (*) () >: public storage1<A1>
|
|
||||||
{
|
|
||||||
typedef storage1<A1> inherited;
|
|
||||||
|
|
||||||
storage2( A1 a1, boost::arg<I> (*) () ): storage1<A1>( a1 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
static boost::arg<I> a2_() { return boost::arg<I>(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 3
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3> struct storage3: public storage2< A1, A2 >
|
|
||||||
{
|
|
||||||
typedef storage2<A1, A2> inherited;
|
|
||||||
|
|
||||||
storage3( A1 a1, A2 a2, A3 a3 ): storage2<A1, A2>( a1, a2 ), a3_( a3 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
BOOST_BIND_VISIT_EACH(v, a3_, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
A3 a3_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
|
|
||||||
|
|
||||||
template<class A1, class A2, int I> struct storage3< A1, A2, boost::arg<I> >: public storage2< A1, A2 >
|
|
||||||
{
|
|
||||||
typedef storage2<A1, A2> inherited;
|
|
||||||
|
|
||||||
storage3( A1 a1, A2 a2, boost::arg<I> ): storage2<A1, A2>( a1, a2 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
static boost::arg<I> a3_() { return boost::arg<I>(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class A1, class A2, int I> struct storage3< A1, A2, boost::arg<I> (*) () >: public storage2< A1, A2 >
|
|
||||||
{
|
|
||||||
typedef storage2<A1, A2> inherited;
|
|
||||||
|
|
||||||
storage3( A1 a1, A2 a2, boost::arg<I> (*) () ): storage2<A1, A2>( a1, a2 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
static boost::arg<I> a3_() { return boost::arg<I>(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 4
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4> struct storage4: public storage3< A1, A2, A3 >
|
|
||||||
{
|
|
||||||
typedef storage3<A1, A2, A3> inherited;
|
|
||||||
|
|
||||||
storage4( A1 a1, A2 a2, A3 a3, A4 a4 ): storage3<A1, A2, A3>( a1, a2, a3 ), a4_( a4 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
BOOST_BIND_VISIT_EACH(v, a4_, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
A4 a4_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, int I> struct storage4< A1, A2, A3, boost::arg<I> >: public storage3< A1, A2, A3 >
|
|
||||||
{
|
|
||||||
typedef storage3<A1, A2, A3> inherited;
|
|
||||||
|
|
||||||
storage4( A1 a1, A2 a2, A3 a3, boost::arg<I> ): storage3<A1, A2, A3>( a1, a2, a3 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
static boost::arg<I> a4_() { return boost::arg<I>(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, int I> struct storage4< A1, A2, A3, boost::arg<I> (*) () >: public storage3< A1, A2, A3 >
|
|
||||||
{
|
|
||||||
typedef storage3<A1, A2, A3> inherited;
|
|
||||||
|
|
||||||
storage4( A1 a1, A2 a2, A3 a3, boost::arg<I> (*) () ): storage3<A1, A2, A3>( a1, a2, a3 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
static boost::arg<I> a4_() { return boost::arg<I>(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 5
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5> struct storage5: public storage4< A1, A2, A3, A4 >
|
|
||||||
{
|
|
||||||
typedef storage4<A1, A2, A3, A4> inherited;
|
|
||||||
|
|
||||||
storage5( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5 ): storage4<A1, A2, A3, A4>( a1, a2, a3, a4 ), a5_( a5 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
BOOST_BIND_VISIT_EACH(v, a5_, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
A5 a5_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, int I> struct storage5< A1, A2, A3, A4, boost::arg<I> >: public storage4< A1, A2, A3, A4 >
|
|
||||||
{
|
|
||||||
typedef storage4<A1, A2, A3, A4> inherited;
|
|
||||||
|
|
||||||
storage5( A1 a1, A2 a2, A3 a3, A4 a4, boost::arg<I> ): storage4<A1, A2, A3, A4>( a1, a2, a3, a4 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
static boost::arg<I> a5_() { return boost::arg<I>(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, int I> struct storage5< A1, A2, A3, A4, boost::arg<I> (*) () >: public storage4< A1, A2, A3, A4 >
|
|
||||||
{
|
|
||||||
typedef storage4<A1, A2, A3, A4> inherited;
|
|
||||||
|
|
||||||
storage5( A1 a1, A2 a2, A3 a3, A4 a4, boost::arg<I> (*) () ): storage4<A1, A2, A3, A4>( a1, a2, a3, a4 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
static boost::arg<I> a5_() { return boost::arg<I>(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 6
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5, class A6> struct storage6: public storage5< A1, A2, A3, A4, A5 >
|
|
||||||
{
|
|
||||||
typedef storage5<A1, A2, A3, A4, A5> inherited;
|
|
||||||
|
|
||||||
storage6( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6 ): storage5<A1, A2, A3, A4, A5>( a1, a2, a3, a4, a5 ), a6_( a6 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
BOOST_BIND_VISIT_EACH(v, a6_, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
A6 a6_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5, int I> struct storage6< A1, A2, A3, A4, A5, boost::arg<I> >: public storage5< A1, A2, A3, A4, A5 >
|
|
||||||
{
|
|
||||||
typedef storage5<A1, A2, A3, A4, A5> inherited;
|
|
||||||
|
|
||||||
storage6( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, boost::arg<I> ): storage5<A1, A2, A3, A4, A5>( a1, a2, a3, a4, a5 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
static boost::arg<I> a6_() { return boost::arg<I>(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5, int I> struct storage6< A1, A2, A3, A4, A5, boost::arg<I> (*) () >: public storage5< A1, A2, A3, A4, A5 >
|
|
||||||
{
|
|
||||||
typedef storage5<A1, A2, A3, A4, A5> inherited;
|
|
||||||
|
|
||||||
storage6( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, boost::arg<I> (*) () ): storage5<A1, A2, A3, A4, A5>( a1, a2, a3, a4, a5 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
static boost::arg<I> a6_() { return boost::arg<I>(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 7
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> struct storage7: public storage6< A1, A2, A3, A4, A5, A6 >
|
|
||||||
{
|
|
||||||
typedef storage6<A1, A2, A3, A4, A5, A6> inherited;
|
|
||||||
|
|
||||||
storage7( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7 ): storage6<A1, A2, A3, A4, A5, A6>( a1, a2, a3, a4, a5, a6 ), a7_( a7 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
BOOST_BIND_VISIT_EACH(v, a7_, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
A7 a7_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5, class A6, int I> struct storage7< A1, A2, A3, A4, A5, A6, boost::arg<I> >: public storage6< A1, A2, A3, A4, A5, A6 >
|
|
||||||
{
|
|
||||||
typedef storage6<A1, A2, A3, A4, A5, A6> inherited;
|
|
||||||
|
|
||||||
storage7( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, boost::arg<I> ): storage6<A1, A2, A3, A4, A5, A6>( a1, a2, a3, a4, a5, a6 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
static boost::arg<I> a7_() { return boost::arg<I>(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5, class A6, int I> struct storage7< A1, A2, A3, A4, A5, A6, boost::arg<I> (*) () >: public storage6< A1, A2, A3, A4, A5, A6 >
|
|
||||||
{
|
|
||||||
typedef storage6<A1, A2, A3, A4, A5, A6> inherited;
|
|
||||||
|
|
||||||
storage7( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, boost::arg<I> (*) () ): storage6<A1, A2, A3, A4, A5, A6>( a1, a2, a3, a4, a5, a6 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
static boost::arg<I> a7_() { return boost::arg<I>(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 8
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> struct storage8: public storage7< A1, A2, A3, A4, A5, A6, A7 >
|
|
||||||
{
|
|
||||||
typedef storage7<A1, A2, A3, A4, A5, A6, A7> inherited;
|
|
||||||
|
|
||||||
storage8( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8 ): storage7<A1, A2, A3, A4, A5, A6, A7>( a1, a2, a3, a4, a5, a6, a7 ), a8_( a8 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
BOOST_BIND_VISIT_EACH(v, a8_, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
A8 a8_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, int I> struct storage8< A1, A2, A3, A4, A5, A6, A7, boost::arg<I> >: public storage7< A1, A2, A3, A4, A5, A6, A7 >
|
|
||||||
{
|
|
||||||
typedef storage7<A1, A2, A3, A4, A5, A6, A7> inherited;
|
|
||||||
|
|
||||||
storage8( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, boost::arg<I> ): storage7<A1, A2, A3, A4, A5, A6, A7>( a1, a2, a3, a4, a5, a6, a7 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
static boost::arg<I> a8_() { return boost::arg<I>(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, int I> struct storage8< A1, A2, A3, A4, A5, A6, A7, boost::arg<I> (*) () >: public storage7< A1, A2, A3, A4, A5, A6, A7 >
|
|
||||||
{
|
|
||||||
typedef storage7<A1, A2, A3, A4, A5, A6, A7> inherited;
|
|
||||||
|
|
||||||
storage8( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, boost::arg<I> (*) () ): storage7<A1, A2, A3, A4, A5, A6, A7>( a1, a2, a3, a4, a5, a6, a7 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
static boost::arg<I> a8_() { return boost::arg<I>(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 9
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> struct storage9: public storage8< A1, A2, A3, A4, A5, A6, A7, A8 >
|
|
||||||
{
|
|
||||||
typedef storage8<A1, A2, A3, A4, A5, A6, A7, A8> inherited;
|
|
||||||
|
|
||||||
storage9( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9 ): storage8<A1, A2, A3, A4, A5, A6, A7, A8>( a1, a2, a3, a4, a5, a6, a7, a8 ), a9_( a9 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
BOOST_BIND_VISIT_EACH(v, a9_, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
A9 a9_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, int I> struct storage9< A1, A2, A3, A4, A5, A6, A7, A8, boost::arg<I> >: public storage8< A1, A2, A3, A4, A5, A6, A7, A8 >
|
|
||||||
{
|
|
||||||
typedef storage8<A1, A2, A3, A4, A5, A6, A7, A8> inherited;
|
|
||||||
|
|
||||||
storage9( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, boost::arg<I> ): storage8<A1, A2, A3, A4, A5, A6, A7, A8>( a1, a2, a3, a4, a5, a6, a7, a8 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
static boost::arg<I> a9_() { return boost::arg<I>(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, int I> struct storage9< A1, A2, A3, A4, A5, A6, A7, A8, boost::arg<I> (*) () >: public storage8< A1, A2, A3, A4, A5, A6, A7, A8 >
|
|
||||||
{
|
|
||||||
typedef storage8<A1, A2, A3, A4, A5, A6, A7, A8> inherited;
|
|
||||||
|
|
||||||
storage9( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, boost::arg<I> (*) () ): storage8<A1, A2, A3, A4, A5, A6, A7, A8>( a1, a2, a3, a4, a5, a6, a7, a8 ) {}
|
|
||||||
|
|
||||||
template<class V> void accept(V & v) const
|
|
||||||
{
|
|
||||||
inherited::accept(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
static boost::arg<I> a9_() { return boost::arg<I>(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace _bi
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
#ifdef BOOST_MSVC
|
|
||||||
# pragma warning(default: 4512) // assignment operator could not be generated
|
|
||||||
# pragma warning(pop)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // #ifndef BOOST_BIND_STORAGE_HPP_INCLUDED
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
#ifndef BOOST_IS_PLACEHOLDER_HPP_INCLUDED
|
|
||||||
#define BOOST_IS_PLACEHOLDER_HPP_INCLUDED
|
|
||||||
|
|
||||||
// MS compatible compilers support #pragma once
|
|
||||||
|
|
||||||
#if defined( _MSC_VER ) && ( _MSC_VER >= 1020 )
|
|
||||||
# pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// is_placeholder.hpp - TR1 is_placeholder metafunction
|
|
||||||
//
|
|
||||||
// Copyright (c) 2006 Peter Dimov
|
|
||||||
//
|
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
|
||||||
//
|
|
||||||
// See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt
|
|
||||||
|
|
||||||
|
|
||||||
namespace boost
|
|
||||||
{
|
|
||||||
|
|
||||||
template< class T > struct is_placeholder
|
|
||||||
{
|
|
||||||
enum _vt { value = 0 };
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
#endif // #ifndef BOOST_IS_PLACEHOLDER_HPP_INCLUDED
|
|
||||||
@@ -328,6 +328,11 @@ private:
|
|||||||
return (u.*f_);
|
return (u.*f_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class U> R & call(U & u, T *) const
|
||||||
|
{
|
||||||
|
return (u.*f_);
|
||||||
|
}
|
||||||
|
|
||||||
template<class U> R const & call(U & u, void const *) const
|
template<class U> R const & call(U & u, void const *) const
|
||||||
{
|
{
|
||||||
return (get_pointer(u)->*f_);
|
return (get_pointer(u)->*f_);
|
||||||
@@ -347,7 +352,7 @@ public:
|
|||||||
return (p->*f_);
|
return (p->*f_);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class U> R const & operator()(U const & u) const
|
template<class U> R const & operator()(U & u) const
|
||||||
{
|
{
|
||||||
return call(u, &u);
|
return call(u, &u);
|
||||||
}
|
}
|
||||||
@@ -359,13 +364,13 @@ public:
|
|||||||
return (t.*f_);
|
return (t.*f_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
R const & operator()(T const & t) const
|
R const & operator()(T const & t) const
|
||||||
{
|
{
|
||||||
return (t.*f_);
|
return (t.*f_);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool operator==(dm const & rhs) const
|
bool operator==(dm const & rhs) const
|
||||||
{
|
{
|
||||||
return f_ == rhs.f_;
|
return f_ == rhs.f_;
|
||||||
|
|||||||
@@ -8,9 +8,3 @@ Automatic redirection failed, please go to
|
|||||||
<a href="mem_fn.html">mem_fn.html</a>.
|
<a href="mem_fn.html">mem_fn.html</a>.
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
<!--
|
|
||||||
© Copyright Beman Dawes, 2001
|
|
||||||
Distributed under the Boost Software License, Version 1.0.
|
|
||||||
See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
http://www.boost.org/LICENSE_1_0.txt
|
|
||||||
-->
|
|
||||||
|
|||||||
411
mem_fn.html
411
mem_fn.html
@@ -1,406 +1,9 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Boost: mem_fn.hpp documentation</title>
|
<meta http-equiv="refresh" content="0; URL=../bind/mem_fn.html">
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
</head>
|
||||||
</head>
|
<body>
|
||||||
<body bgcolor="white" style="MARGIN-LEFT: 5%; MARGIN-RIGHT: 5%">
|
Automatic redirection failed, please go to
|
||||||
<table border="0" width="100%">
|
<a href="../bind/mem_fn.html">../bind/mem_fn.html</a>.
|
||||||
<tr>
|
</body>
|
||||||
<td width="277"><A href="../../index.htm"> <img src="../../boost.png" alt="boost.png (6897 bytes)" width="277" height="86" border="0"></A>
|
|
||||||
</td>
|
|
||||||
<td align="center">
|
|
||||||
<h1>mem_fn.hpp</h1>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="2" height="64"> </td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<h2>Contents</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">"__stdcall", "__cdecl" and
|
|
||||||
"__fastcall" 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 <b>std::mem_fun</b>
|
|
||||||
and <b>std::mem_fun_ref</b>. It supports member function pointers with more
|
|
||||||
than one argument, and the returned function object can take a pointer, a
|
|
||||||
reference, or a smart pointer to an object instance as its first argument. <STRONG>mem_fn</STRONG>
|
|
||||||
also supports pointers to data members by treating them as functions taking no
|
|
||||||
arguments and returning a (const) reference to the member.
|
|
||||||
</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(&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<class It, class R, class T> 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(), &Shape::draw);
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
When documenting the feature, the library author will simply state:
|
|
||||||
</p>
|
|
||||||
<h4 style="MARGIN-LEFT: 20pt">template<class It, class R, class T> 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, and returns a function
|
|
||||||
object suitable for use with standard or user-defined algorithms:
|
|
||||||
</p>
|
|
||||||
<pre>
|
|
||||||
struct X
|
|
||||||
{
|
|
||||||
void f();
|
|
||||||
};
|
|
||||||
|
|
||||||
void g(std::vector<X> & v)
|
|
||||||
{
|
|
||||||
std::for_each(v.begin(), v.end(), boost::mem_fn(&X::f));
|
|
||||||
};
|
|
||||||
|
|
||||||
void h(std::vector<X *> const & v)
|
|
||||||
{
|
|
||||||
std::for_each(v.begin(), v.end(), boost::mem_fn(&X::f));
|
|
||||||
};
|
|
||||||
|
|
||||||
void k(std::vector<boost::shared_ptr<X> > const & v)
|
|
||||||
{
|
|
||||||
std::for_each(v.begin(), v.end(), boost::mem_fn(&X::f));
|
|
||||||
};
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
The returned function object takes the same arguments as the input member
|
|
||||||
function plus a "flexible" first argument that represents the object instance.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
When the function object is invoked with a first argument <b>x</b> that is
|
|
||||||
neither a pointer nor a reference to the appropriate class (<b>X</b> in the
|
|
||||||
example above), it uses <tt>get_pointer(x)</tt> to obtain a pointer from <b>x</b>.
|
|
||||||
Library authors can "register" their smart pointer classes by supplying an
|
|
||||||
appropriate <b>get_pointer</b> overload, allowing <b>mem_fn</b> to recognize
|
|
||||||
and support them.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
[Note: <b>get_pointer</b> is not restricted to return a pointer. Any object
|
|
||||||
that can be used in a member function call expression <tt>(x->*pmf)(...)</tt>
|
|
||||||
will work.]
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
[Note: the library uses an unqualified call to <b>get_pointer</b>. Therefore,
|
|
||||||
it will find, through argument-dependent lookup, <b>get_pointer</b> overloads
|
|
||||||
that are defined in the same namespace as the corresponding smart pointer
|
|
||||||
class, in addition to any <b>boost::get_pointer</b> overloads.]
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
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. For data members, <STRONG>result_type</STRONG>
|
|
||||||
is defined as the type of the member.
|
|
||||||
</p>
|
|
||||||
<h2><a name="FAQ">Frequently Asked Questions</a></h2>
|
|
||||||
<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. In addition, it is possible for the default
|
|
||||||
calling convention to be __stdcall, in which case enabling __stdcall support
|
|
||||||
will result in duplicate definitions.
|
|
||||||
</p>
|
|
||||||
<h2><a name="Interface">Interface</a></h2>
|
|
||||||
<h3><a name="Synopsis">Synopsis</a></h3>
|
|
||||||
<pre>
|
|
||||||
namespace boost
|
|
||||||
{
|
|
||||||
|
|
||||||
template<class T> T * <a href="#get_pointer_1">get_pointer</a>(T * p);
|
|
||||||
|
|
||||||
template<class R, class T> <i>unspecified-1</i> <a href="#mem_fn_1">mem_fn</a>(R (T::*pmf) ());
|
|
||||||
|
|
||||||
template<class R, class T> <i>unspecified-2</i> <a href="#mem_fn_2">mem_fn</a>(R (T::*pmf) () const);
|
|
||||||
|
|
||||||
template<class R, class T> <i>unspecified-2-1</i> <a href="#mem_fn_2_1">mem_fn</a>(R T::*pm);
|
|
||||||
|
|
||||||
template<class R, class T, class A1> <i>unspecified-3</i> <a href="#mem_fn_3">mem_fn</a>(R (T::*pmf) (A1));
|
|
||||||
|
|
||||||
template<class R, class T, class A1> <i>unspecified-4</i> <a href="#mem_fn_4">mem_fn</a>(R (T::*pmf) (A1) const);
|
|
||||||
|
|
||||||
template<class R, class T, class A1, class A2> <i>unspecified-5</i> <a href="#mem_fn_5">mem_fn</a>(R (T::*pmf) (A1, A2));
|
|
||||||
|
|
||||||
template<class R, class T, class A1, class A2> <i>unspecified-6</i> <a href="#mem_fn_6">mem_fn</a>(R (T::*pmf) (A1, A2) const);
|
|
||||||
|
|
||||||
// implementation defined number of additional overloads for more arguments
|
|
||||||
|
|
||||||
}
|
|
||||||
</pre>
|
|
||||||
<h3><a name="CommonRequirements">Common requirements</a></h3>
|
|
||||||
<p>
|
|
||||||
All <tt><i>unspecified-N</i></tt> types mentioned in the Synopsis are <b>CopyConstructible</b>
|
|
||||||
and <b>Assignable</b>. Their copy constructors and assignment operators do not
|
|
||||||
throw exceptions. <tt><i>unspecified-N</i>::result_type</tt> is defined as the
|
|
||||||
return type of the member function pointer passed as an argument to <b>mem_fn</b>
|
|
||||||
(<b>R</b> in the Synopsis.) <tt><i>unspecified-2-1</i>::result_type</tt> is
|
|
||||||
defined as <tt>R</tt>.
|
|
||||||
</p>
|
|
||||||
<h3><a name="get_pointer">get_pointer</a></h3>
|
|
||||||
<h4><a name="get_pointer_1">template<class T> T * get_pointer(T * p)</a></h4>
|
|
||||||
<blockquote>
|
|
||||||
<p>
|
|
||||||
<b>Returns:</b> <tt>p</tt>.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<b>Throws:</b> Nothing.
|
|
||||||
</p>
|
|
||||||
</blockquote>
|
|
||||||
<h3><a name="mem_fn">mem_fn</a></h3>
|
|
||||||
<h4><a name="mem_fn_1">template<class R, class T> <i>unspecified-1</i> mem_fn(R
|
|
||||||
(T::*pmf) ())</a></h4>
|
|
||||||
<blockquote>
|
|
||||||
<p>
|
|
||||||
<b>Returns:</b> a function object <i>f</i> such that the expression <tt><i>f(t)</i></tt>
|
|
||||||
is equivalent to <tt>(t.*pmf)()</tt> when <i>t</i> is an l-value of type <STRONG>T </STRONG>
|
|
||||||
or derived, <tt>(get_pointer(t)->*pmf)()</tt> otherwise.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<b>Throws:</b> Nothing.
|
|
||||||
</p>
|
|
||||||
</blockquote>
|
|
||||||
<h4><a name="mem_fn_2">template<class R, class T> <i>unspecified-2</i> mem_fn(R
|
|
||||||
(T::*pmf) () const)</a></h4>
|
|
||||||
<blockquote>
|
|
||||||
<p>
|
|
||||||
<b>Returns:</b> a function object <i>f</i> such that the expression <tt><i>f(t)</i></tt>
|
|
||||||
is equivalent to <tt>(t.*pmf)()</tt> when <i>t</i> is of type <STRONG>T</STRONG>
|
|
||||||
<EM>[const]<STRONG> </STRONG></EM>or derived, <tt>(get_pointer(t)->*pmf)()</tt>
|
|
||||||
otherwise.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<b>Throws:</b> Nothing.
|
|
||||||
</p>
|
|
||||||
</blockquote>
|
|
||||||
<h4><a name="mem_fn_2_1">template<class R, class T> <i>unspecified-2-1</i> mem_fn(R
|
|
||||||
T::*pm)</a></h4>
|
|
||||||
<blockquote>
|
|
||||||
<p>
|
|
||||||
<b>Returns:</b> a function object <i>f</i> such that the expression <tt><i>f(t)</i></tt>
|
|
||||||
is equivalent to <tt>t.*pm</tt> when <i>t</i> is of type <STRONG>T</STRONG> <EM>[const]<STRONG>
|
|
||||||
</STRONG></EM>or derived, <tt>get_pointer(t)->*pm</tt> otherwise.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<b>Throws:</b> Nothing.
|
|
||||||
</p>
|
|
||||||
</blockquote>
|
|
||||||
<h4><a name="mem_fn_3">template<class R, class T, class A1> <i>unspecified-3</i> mem_fn(R
|
|
||||||
(T::*pmf) (A1))</a></h4>
|
|
||||||
<blockquote>
|
|
||||||
<p>
|
|
||||||
<b>Returns:</b> a function object <i>f</i> such that the expression <tt><i>f(t, a1)</i></tt>
|
|
||||||
is equivalent to <tt>(t.*pmf)(a1)</tt> when <i>t</i> is an l-value of type <STRONG>T
|
|
||||||
</STRONG>or derived, <tt>(get_pointer(t)->*pmf)(a1)</tt> otherwise.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<b>Throws:</b> Nothing.
|
|
||||||
</p>
|
|
||||||
</blockquote>
|
|
||||||
<h4><a name="mem_fn_4">template<class R, class T, class A1> <i>unspecified-4</i> mem_fn(R
|
|
||||||
(T::*pmf) (A1) const)</a></h4>
|
|
||||||
<blockquote>
|
|
||||||
<p>
|
|
||||||
<b>Returns:</b> a function object <i>f</i> such that the expression <tt><i>f(t, a1)</i></tt>
|
|
||||||
is equivalent to <tt>(t.*pmf)(a1)</tt> when <i>t</i> is of type <STRONG>T</STRONG>
|
|
||||||
<EM>[const]<STRONG> </STRONG></EM>or derived, <tt>(get_pointer(t)->*pmf)(a1)</tt>
|
|
||||||
otherwise.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<b>Throws:</b> Nothing.
|
|
||||||
</p>
|
|
||||||
</blockquote>
|
|
||||||
<h4><a name="mem_fn_5">template<class R, class T, class A1, class A2> <i>unspecified-5</i>
|
|
||||||
mem_fn(R (T::*pmf) (A1, A2))</a></h4>
|
|
||||||
<blockquote>
|
|
||||||
<p>
|
|
||||||
<b>Returns:</b> a function object <i>f</i> such that the expression <tt><i>f(t, a1, a2)</i></tt>
|
|
||||||
is equivalent to <tt>(t.*pmf)(a1, a2)</tt> when <i>t</i> is an l-value of type <STRONG>
|
|
||||||
T</STRONG> or derived, <tt>(get_pointer(t)->*pmf)(a1, a2)</tt> otherwise.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<b>Throws:</b> Nothing.
|
|
||||||
</p>
|
|
||||||
</blockquote>
|
|
||||||
<h4><a name="mem_fn_6">template<class R, class T, class A1, class A2> <i>unspecified-6</i>
|
|
||||||
mem_fn(R (T::*pmf) (A1, A2) const)</a></h4>
|
|
||||||
<blockquote>
|
|
||||||
<p>
|
|
||||||
<b>Returns:</b> a function object <i>f</i> such that the expression <tt><i>f(t, a1, a2)</i></tt>
|
|
||||||
is equivalent to <tt>(t.*pmf)(a1, a2)</tt> when <i>t</i> is of type <STRONG>T</STRONG>
|
|
||||||
<EM>[const]</EM> or derived, <tt>(get_pointer(t)->*pmf)(a1, a2)</tt> otherwise.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<b>Throws:</b> Nothing.
|
|
||||||
</p>
|
|
||||||
</blockquote>
|
|
||||||
<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="test/mem_fn_test.cpp">libs/bind/test/mem_fn_test.cpp</a>
|
|
||||||
(test)
|
|
||||||
<li>
|
|
||||||
<a href="test/mem_fn_derived_test.cpp">libs/bind/test/mem_fn_derived_test.cpp</a>
|
|
||||||
(test with derived objects)
|
|
||||||
<li>
|
|
||||||
<a href="test/mem_fn_fastcall_test.cpp">libs/bind/test/mem_fn_fastcall_test.cpp</a>
|
|
||||||
(test for __fastcall)
|
|
||||||
<li>
|
|
||||||
<a href="test/mem_fn_stdcall_test.cpp">libs/bind/test/mem_fn_stdcall_test.cpp</a>
|
|
||||||
(test for __stdcall)
|
|
||||||
<li>
|
|
||||||
<a href="test/mem_fn_void_test.cpp">libs/bind/test/mem_fn_void_test.cpp</a> (test
|
|
||||||
for void returns)</li>
|
|
||||||
</ul>
|
|
||||||
<h3><a name="Dependencies">Dependencies</a></h3>
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
<a href="../config/config.htm">Boost.Config</a></li>
|
|
||||||
</ul>
|
|
||||||
<h3><a name="NumberOfArguments">Number of Arguments</a></h3>
|
|
||||||
<p>
|
|
||||||
This implementation supports member functions with up to eight arguments. This
|
|
||||||
is not an inherent limitation of the design, but an implementation detail.
|
|
||||||
</p>
|
|
||||||
<h3><a name="stdcall">"__stdcall", "__cdecl" and "__fastcall" 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>. Borland VCL components use <STRONG>__fastcall</STRONG>.
|
|
||||||
UDK, the component model of OpenOffice.org, uses <STRONG>__cdecl</STRONG>.
|
|
||||||
</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><boost/mem_fn.hpp></b>.
|
|
||||||
</p>
|
|
||||||
<P>To use <B>mem_fn</B> with <B>__fastcall</B> member functions, <B>#define</B> the
|
|
||||||
macro <B>BOOST_MEM_FN_ENABLE_FASTCALL</B> before including <B><boost/mem_fn.hpp></B>.
|
|
||||||
</P>
|
|
||||||
<P>To use <B>mem_fn</B> with <B>__cdecl</B> member functions, <B>#define</B> the
|
|
||||||
macro <B>BOOST_MEM_FN_ENABLE_CDECL</B> before including <B><boost/mem_fn.hpp></B>.
|
|
||||||
</P>
|
|
||||||
<P><STRONG>It is best to define these macros in the project options, via -D on the
|
|
||||||
command line, or as the first line in the translation unit (.cpp file) where
|
|
||||||
mem_fn is used.</STRONG> Not following this rule can lead to obscure errors
|
|
||||||
when a header includes mem_fn.hpp before the macro has been defined.</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 <b>mem_fn</b> adapt
|
|
||||||
to user-defined smart pointers inspired the <b>get_pointer</b>-based design.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Numerous improvements were suggested during the formal review period by 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>Daniel Boelzle pointed out that UDK uses <STRONG>__cdecl</STRONG>.<br>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<small>Copyright © 2001, 2002 by Peter Dimov and Multi Media Ltd. Copyright
|
|
||||||
2003-2005 Peter Dimov. Distributed under the Boost Software License, Version
|
|
||||||
1.0. See accompanying file <A href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</A> or
|
|
||||||
copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>.</small></p>
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
6
ref.html
6
ref.html
@@ -7,9 +7,3 @@ Automatic redirection failed, please go to
|
|||||||
<a href="../../doc/html/ref.html">../../doc/html/ref.html</a>
|
<a href="../../doc/html/ref.html">../../doc/html/ref.html</a>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
<!--
|
|
||||||
© Copyright Beman Dawes, 2001
|
|
||||||
Distributed under the Boost Software License, Version 1.0.
|
|
||||||
See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
http://www.boost.org/LICENSE_1_0.txt
|
|
||||||
-->
|
|
||||||
|
|||||||
37
test/Jamfile
Normal file
37
test/Jamfile
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# Boost.Bind Library test Jamfile
|
||||||
|
#
|
||||||
|
# Copyright (c) 2003-2005 Peter Dimov
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
subproject libs/bind/test ;
|
||||||
|
|
||||||
|
# bring in rules for testing
|
||||||
|
import testing ;
|
||||||
|
|
||||||
|
# Make tests run by default.
|
||||||
|
DEPENDS all : bind ;
|
||||||
|
|
||||||
|
{
|
||||||
|
test-suite "bind"
|
||||||
|
: [ run bind_test.cpp ]
|
||||||
|
[ run bind_dm_test.cpp ]
|
||||||
|
[ run bind_eq_test.cpp ]
|
||||||
|
[ run bind_const_test.cpp ]
|
||||||
|
[ run bind_cv_test.cpp ]
|
||||||
|
[ run bind_stateful_test.cpp ]
|
||||||
|
[ run bind_dm2_test.cpp ]
|
||||||
|
[ run bind_not_test.cpp ]
|
||||||
|
[ run bind_rel_test.cpp ]
|
||||||
|
[ run bind_function_test.cpp ]
|
||||||
|
[ run bind_lookup_problem_test.cpp ]
|
||||||
|
[ run mem_fn_test.cpp ]
|
||||||
|
[ run mem_fn_void_test.cpp ]
|
||||||
|
[ run mem_fn_derived_test.cpp ]
|
||||||
|
[ run mem_fn_eq_test.cpp ]
|
||||||
|
[ run mem_fn_dm_test.cpp ]
|
||||||
|
;
|
||||||
|
}
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
# Boost.Bind Library test Jamfile
|
# Boost.Bind Library test Jamfile
|
||||||
#
|
#
|
||||||
# Copyright (c) 2003-2006 Peter Dimov
|
# Copyright (c) 2003-2005 Peter Dimov
|
||||||
#
|
#
|
||||||
# Distributed under the Boost Software License, Version 1.0. (See
|
# Permission to copy, use, modify, sell and distribute this software
|
||||||
# accompanying file LICENSE_1_0.txt or copy at
|
# is granted provided this copyright notice appears in all copies.
|
||||||
# http://www.boost.org/LICENSE_1_0.txt)
|
# This software is provided "as is" without express or implied
|
||||||
|
# warranty, and with no claim as to its suitability for any purpose.
|
||||||
|
|
||||||
# bring in rules for testing
|
# bring in rules for testing
|
||||||
import testing ;
|
import testing ;
|
||||||
@@ -21,21 +22,9 @@ test-suite "bind"
|
|||||||
[ run bind_rel_test.cpp ]
|
[ run bind_rel_test.cpp ]
|
||||||
[ run bind_function_test.cpp ]
|
[ run bind_function_test.cpp ]
|
||||||
[ run bind_lookup_problem_test.cpp ]
|
[ run bind_lookup_problem_test.cpp ]
|
||||||
[ run bind_rv_sp_test.cpp ]
|
|
||||||
[ compile bind_unary_addr.cpp ]
|
|
||||||
[ run bind_dm3_test.cpp ]
|
|
||||||
[ run bind_visit_test.cpp ]
|
|
||||||
[ run bind_placeholder_test.cpp ]
|
|
||||||
[ run bind_rvalue_test.cpp ]
|
|
||||||
[ run bind_and_or_test.cpp ]
|
|
||||||
[ run mem_fn_test.cpp ]
|
[ run mem_fn_test.cpp ]
|
||||||
[ run mem_fn_void_test.cpp ]
|
[ run mem_fn_void_test.cpp ]
|
||||||
[ run mem_fn_derived_test.cpp ]
|
[ run mem_fn_derived_test.cpp ]
|
||||||
[ run mem_fn_eq_test.cpp ]
|
[ run mem_fn_eq_test.cpp ]
|
||||||
[ run mem_fn_dm_test.cpp ]
|
[ run mem_fn_dm_test.cpp ]
|
||||||
[ run mem_fn_rv_test.cpp ]
|
|
||||||
[ run ref_fn_test.cpp ]
|
|
||||||
[ run bind_fnobj2_test.cpp ]
|
|
||||||
[ run bind_fn2_test.cpp ]
|
|
||||||
[ run bind_mf2_test.cpp ]
|
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -1,84 +0,0 @@
|
|||||||
#include <boost/config.hpp>
|
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
|
||||||
#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_and_or_test.cpp - &&, || operators
|
|
||||||
//
|
|
||||||
// Copyright (c) 2008 Peter Dimov
|
|
||||||
//
|
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See
|
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
|
||||||
|
|
||||||
bool f( bool x )
|
|
||||||
{
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool g( bool x )
|
|
||||||
{
|
|
||||||
return !x;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool h()
|
|
||||||
{
|
|
||||||
BOOST_ERROR( "Short-circuit evaluation failure" );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template< class F, class A1, class A2, class R > void test( F f, A1 a1, A2 a2, R r )
|
|
||||||
{
|
|
||||||
BOOST_TEST( f( a1, a2 ) == r );
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
// &&
|
|
||||||
|
|
||||||
test( boost::bind( f, true ) && boost::bind( g, true ), false, false, f( true ) && g( true ) );
|
|
||||||
test( boost::bind( f, true ) && boost::bind( g, false ), false, false, f( true ) && g( false ) );
|
|
||||||
|
|
||||||
test( boost::bind( f, false ) && boost::bind( h ), false, false, f( false ) && h() );
|
|
||||||
|
|
||||||
test( boost::bind( f, _1 ) && boost::bind( g, _2 ), true, true, f( true ) && g( true ) );
|
|
||||||
test( boost::bind( f, _1 ) && boost::bind( g, _2 ), true, false, f( true ) && g( false ) );
|
|
||||||
|
|
||||||
test( boost::bind( f, _1 ) && boost::bind( h ), false, false, f( false ) && h() );
|
|
||||||
|
|
||||||
// ||
|
|
||||||
|
|
||||||
test( boost::bind( f, false ) || boost::bind( g, true ), false, false, f( false ) || g( true ) );
|
|
||||||
test( boost::bind( f, false ) || boost::bind( g, false ), false, false, f( false ) || g( false ) );
|
|
||||||
|
|
||||||
test( boost::bind( f, true ) || boost::bind( h ), false, false, f( true ) || h() );
|
|
||||||
|
|
||||||
test( boost::bind( f, _1 ) || boost::bind( g, _2 ), false, true, f( false ) || g( true ) );
|
|
||||||
test( boost::bind( f, _1 ) || boost::bind( g, _2 ), false, false, f( false ) || g( false ) );
|
|
||||||
|
|
||||||
test( boost::bind( f, _1 ) || boost::bind( h ), true, false, f( true ) || h() );
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
#include <boost/config.hpp>
|
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
|
||||||
#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_dm3_test.cpp - data members (regression 1.31 - 1.32)
|
|
||||||
//
|
|
||||||
// Copyright (c) 2005 Peter Dimov
|
|
||||||
//
|
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See
|
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
typedef std::pair<int, int> pair_type;
|
|
||||||
|
|
||||||
pair_type pair( 10, 20 );
|
|
||||||
|
|
||||||
int const & x = boost::bind( &pair_type::first, _1 )( pair );
|
|
||||||
|
|
||||||
BOOST_TEST( &pair.first == &x );
|
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
|
||||||
@@ -1,171 +0,0 @@
|
|||||||
#include <boost/config.hpp>
|
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
|
||||||
#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_fn2_test.cpp - test for functions w/ the type<> syntax
|
|
||||||
//
|
|
||||||
// Copyright (c) 2005, 2008 Peter Dimov
|
|
||||||
//
|
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See
|
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
|
||||||
|
|
||||||
long global_result;
|
|
||||||
|
|
||||||
// long
|
|
||||||
|
|
||||||
long f_0()
|
|
||||||
{
|
|
||||||
return global_result = 17041L;
|
|
||||||
}
|
|
||||||
|
|
||||||
long f_1(long a)
|
|
||||||
{
|
|
||||||
return global_result = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
long f_2(long a, long b)
|
|
||||||
{
|
|
||||||
return global_result = a + 10 * b;
|
|
||||||
}
|
|
||||||
|
|
||||||
long f_3(long a, long b, long c)
|
|
||||||
{
|
|
||||||
return global_result = a + 10 * b + 100 * c;
|
|
||||||
}
|
|
||||||
|
|
||||||
long f_4(long a, long b, long c, long d)
|
|
||||||
{
|
|
||||||
return global_result = a + 10 * b + 100 * c + 1000 * d;
|
|
||||||
}
|
|
||||||
|
|
||||||
long f_5(long a, long b, long c, long d, long e)
|
|
||||||
{
|
|
||||||
return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e;
|
|
||||||
}
|
|
||||||
|
|
||||||
long f_6(long a, long b, long c, long d, long e, long f)
|
|
||||||
{
|
|
||||||
return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f;
|
|
||||||
}
|
|
||||||
|
|
||||||
long f_7(long a, long b, long c, long d, long e, long f, long g)
|
|
||||||
{
|
|
||||||
return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g;
|
|
||||||
}
|
|
||||||
|
|
||||||
long f_8(long a, long b, long c, long d, long e, long f, long g, long h)
|
|
||||||
{
|
|
||||||
return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h;
|
|
||||||
}
|
|
||||||
|
|
||||||
long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i)
|
|
||||||
{
|
|
||||||
return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i;
|
|
||||||
}
|
|
||||||
|
|
||||||
// void
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
bind( type<void>(), f_0 )(); BOOST_TEST( global_result == 17041L );
|
|
||||||
bind( type<void>(), f_1, 1 )(); BOOST_TEST( global_result == 1L );
|
|
||||||
bind( type<void>(), f_2, 1, 2 )(); BOOST_TEST( global_result == 21L );
|
|
||||||
bind( type<void>(), f_3, 1, 2, 3 )(); BOOST_TEST( global_result == 321L );
|
|
||||||
bind( type<void>(), f_4, 1, 2, 3, 4 )(); BOOST_TEST( global_result == 4321L );
|
|
||||||
bind( type<void>(), f_5, 1, 2, 3, 4, 5 )(); BOOST_TEST( global_result == 54321L );
|
|
||||||
bind( type<void>(), f_6, 1, 2, 3, 4, 5, 6 )(); BOOST_TEST( global_result == 654321L );
|
|
||||||
bind( type<void>(), f_7, 1, 2, 3, 4, 5, 6, 7 )(); BOOST_TEST( global_result == 7654321L );
|
|
||||||
bind( type<void>(), f_8, 1, 2, 3, 4, 5, 6, 7, 8 )(); BOOST_TEST( global_result == 87654321L );
|
|
||||||
bind( type<void>(), f_9, 1, 2, 3, 4, 5, 6, 7, 8, 9 )(); BOOST_TEST( global_result == 987654321L );
|
|
||||||
|
|
||||||
bind( type<void>(), fv_0 )(); BOOST_TEST( global_result == 17041L );
|
|
||||||
bind( type<void>(), fv_1, 1 )(); BOOST_TEST( global_result == 1L );
|
|
||||||
bind( type<void>(), fv_2, 1, 2 )(); BOOST_TEST( global_result == 21L );
|
|
||||||
bind( type<void>(), fv_3, 1, 2, 3 )(); BOOST_TEST( global_result == 321L );
|
|
||||||
bind( type<void>(), fv_4, 1, 2, 3, 4 )(); BOOST_TEST( global_result == 4321L );
|
|
||||||
bind( type<void>(), fv_5, 1, 2, 3, 4, 5 )(); BOOST_TEST( global_result == 54321L );
|
|
||||||
bind( type<void>(), fv_6, 1, 2, 3, 4, 5, 6 )(); BOOST_TEST( global_result == 654321L );
|
|
||||||
bind( type<void>(), fv_7, 1, 2, 3, 4, 5, 6, 7 )(); BOOST_TEST( global_result == 7654321L );
|
|
||||||
bind( type<void>(), fv_8, 1, 2, 3, 4, 5, 6, 7, 8 )(); BOOST_TEST( global_result == 87654321L );
|
|
||||||
bind( type<void>(), fv_9, 1, 2, 3, 4, 5, 6, 7, 8, 9 )(); BOOST_TEST( global_result == 987654321L );
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
function_test();
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
#include <boost/config.hpp>
|
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
|
||||||
#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_fnobj2_test.cpp - test for function objects w/ the type<> syntax
|
|
||||||
//
|
|
||||||
// Copyright (c) 2005, 2008 Peter Dimov
|
|
||||||
//
|
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See
|
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
|
||||||
|
|
||||||
struct X
|
|
||||||
{
|
|
||||||
mutable unsigned int hash;
|
|
||||||
|
|
||||||
X(): hash(0) {}
|
|
||||||
|
|
||||||
int operator()() const { operator()(17); return 0; }
|
|
||||||
int operator()(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; }
|
|
||||||
int operator()(int a1, int a2) const { operator()(a1); operator()(a2); return 0; }
|
|
||||||
int operator()(int a1, int a2, int a3) const { operator()(a1, a2); operator()(a3); return 0; }
|
|
||||||
int operator()(int a1, int a2, int a3, int a4) const { operator()(a1, a2, a3); operator()(a4); return 0; }
|
|
||||||
int operator()(int a1, int a2, int a3, int a4, int a5) const { operator()(a1, a2, a3, a4); operator()(a5); return 0; }
|
|
||||||
int operator()(int a1, int a2, int a3, int a4, int a5, int a6) const { operator()(a1, a2, a3, a4, a5); operator()(a6); return 0; }
|
|
||||||
int operator()(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { operator()(a1, a2, a3, a4, a5, a6); operator()(a7); return 0; }
|
|
||||||
int operator()(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { operator()(a1, a2, a3, a4, a5, a6, a7); operator()(a8); return 0; }
|
|
||||||
int operator()(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9) const { operator()(a1, a2, a3, a4, a5, a6, a7, a8); operator()(a9); return 0; }
|
|
||||||
};
|
|
||||||
|
|
||||||
void function_object_test()
|
|
||||||
{
|
|
||||||
using namespace boost;
|
|
||||||
|
|
||||||
X x;
|
|
||||||
|
|
||||||
bind( type<void>(), ref(x) )();
|
|
||||||
bind( type<void>(), ref(x), 1 )();
|
|
||||||
bind( type<void>(), ref(x), 1, 2 )();
|
|
||||||
bind( type<void>(), ref(x), 1, 2, 3 )();
|
|
||||||
bind( type<void>(), ref(x), 1, 2, 3, 4 )();
|
|
||||||
bind( type<void>(), ref(x), 1, 2, 3, 4, 5 )();
|
|
||||||
bind( type<void>(), ref(x), 1, 2, 3, 4, 5, 6 )();
|
|
||||||
bind( type<void>(), ref(x), 1, 2, 3, 4, 5, 6, 7)();
|
|
||||||
bind( type<void>(), ref(x), 1, 2, 3, 4, 5, 6, 7, 8 )();
|
|
||||||
bind( type<void>(), ref(x), 1, 2, 3, 4, 5, 6, 7, 8, 9 )();
|
|
||||||
|
|
||||||
BOOST_TEST( x.hash == 9932 );
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
function_object_test();
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// bind_lookup_problem_test.cpp
|
// bind_lookup_problem_test.cpp
|
||||||
//
|
//
|
||||||
// Copyright (C) Markus Schoepflin 2005.
|
// Copyright (C) Markus Schöpflin 2005.
|
||||||
//
|
//
|
||||||
// Use, modification, and distribution are subject to the Boost Software
|
// Use, modification, and distribution are subject to the Boost Software
|
||||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
|||||||
@@ -1,162 +0,0 @@
|
|||||||
#include <boost/config.hpp>
|
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
|
||||||
#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_mf2_test.cpp - test for member functions w/ the type<> syntax
|
|
||||||
//
|
|
||||||
// Copyright (c) 2005, 2008 Peter Dimov
|
|
||||||
//
|
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See
|
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
|
||||||
|
|
||||||
struct X
|
|
||||||
{
|
|
||||||
mutable unsigned int hash;
|
|
||||||
|
|
||||||
X(): 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; }
|
|
||||||
};
|
|
||||||
|
|
||||||
void member_function_test()
|
|
||||||
{
|
|
||||||
using namespace boost;
|
|
||||||
|
|
||||||
X x;
|
|
||||||
|
|
||||||
// 0
|
|
||||||
|
|
||||||
bind( type<void>(), &X::f0, &x )();
|
|
||||||
bind( type<void>(), &X::f0, ref(x) )();
|
|
||||||
|
|
||||||
bind( type<void>(), &X::g0, &x )();
|
|
||||||
bind( type<void>(), &X::g0, x )();
|
|
||||||
bind( type<void>(), &X::g0, ref(x) )();
|
|
||||||
|
|
||||||
// 1
|
|
||||||
|
|
||||||
bind( type<void>(), &X::f1, &x, 1 )();
|
|
||||||
bind( type<void>(), &X::f1, ref(x), 1 )();
|
|
||||||
|
|
||||||
bind( type<void>(), &X::g1, &x, 1 )();
|
|
||||||
bind( type<void>(), &X::g1, x, 1 )();
|
|
||||||
bind( type<void>(), &X::g1, ref(x), 1 )();
|
|
||||||
|
|
||||||
// 2
|
|
||||||
|
|
||||||
bind( type<void>(), &X::f2, &x, 1, 2 )();
|
|
||||||
bind( type<void>(), &X::f2, ref(x), 1, 2 )();
|
|
||||||
|
|
||||||
bind( type<void>(), &X::g2, &x, 1, 2 )();
|
|
||||||
bind( type<void>(), &X::g2, x, 1, 2 )();
|
|
||||||
bind( type<void>(), &X::g2, ref(x), 1, 2 )();
|
|
||||||
|
|
||||||
// 3
|
|
||||||
|
|
||||||
bind( type<void>(), &X::f3, &x, 1, 2, 3 )();
|
|
||||||
bind( type<void>(), &X::f3, ref(x), 1, 2, 3 )();
|
|
||||||
|
|
||||||
bind( type<void>(), &X::g3, &x, 1, 2, 3 )();
|
|
||||||
bind( type<void>(), &X::g3, x, 1, 2, 3 )();
|
|
||||||
bind( type<void>(), &X::g3, ref(x), 1, 2, 3 )();
|
|
||||||
|
|
||||||
// 4
|
|
||||||
|
|
||||||
bind( type<void>(), &X::f4, &x, 1, 2, 3, 4 )();
|
|
||||||
bind( type<void>(), &X::f4, ref(x), 1, 2, 3, 4 )();
|
|
||||||
|
|
||||||
bind( type<void>(), &X::g4, &x, 1, 2, 3, 4 )();
|
|
||||||
bind( type<void>(), &X::g4, x, 1, 2, 3, 4 )();
|
|
||||||
bind( type<void>(), &X::g4, ref(x), 1, 2, 3, 4 )();
|
|
||||||
|
|
||||||
// 5
|
|
||||||
|
|
||||||
bind( type<void>(), &X::f5, &x, 1, 2, 3, 4, 5 )();
|
|
||||||
bind( type<void>(), &X::f5, ref(x), 1, 2, 3, 4, 5 )();
|
|
||||||
|
|
||||||
bind( type<void>(), &X::g5, &x, 1, 2, 3, 4, 5 )();
|
|
||||||
bind( type<void>(), &X::g5, x, 1, 2, 3, 4, 5 )();
|
|
||||||
bind( type<void>(), &X::g5, ref(x), 1, 2, 3, 4, 5 )();
|
|
||||||
|
|
||||||
// 6
|
|
||||||
|
|
||||||
bind( type<void>(), &X::f6, &x, 1, 2, 3, 4, 5, 6 )();
|
|
||||||
bind( type<void>(), &X::f6, ref(x), 1, 2, 3, 4, 5, 6 )();
|
|
||||||
|
|
||||||
bind( type<void>(), &X::g6, &x, 1, 2, 3, 4, 5, 6 )();
|
|
||||||
bind( type<void>(), &X::g6, x, 1, 2, 3, 4, 5, 6 )();
|
|
||||||
bind( type<void>(), &X::g6, ref(x), 1, 2, 3, 4, 5, 6 )();
|
|
||||||
|
|
||||||
// 7
|
|
||||||
|
|
||||||
bind( type<void>(), &X::f7, &x, 1, 2, 3, 4, 5, 6, 7)();
|
|
||||||
bind( type<void>(), &X::f7, ref(x), 1, 2, 3, 4, 5, 6, 7)();
|
|
||||||
|
|
||||||
bind( type<void>(), &X::g7, &x, 1, 2, 3, 4, 5, 6, 7)();
|
|
||||||
bind( type<void>(), &X::g7, x, 1, 2, 3, 4, 5, 6, 7)();
|
|
||||||
bind( type<void>(), &X::g7, ref(x), 1, 2, 3, 4, 5, 6, 7)();
|
|
||||||
|
|
||||||
// 8
|
|
||||||
|
|
||||||
bind( type<void>(), &X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8 )();
|
|
||||||
bind( type<void>(), &X::f8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8 )();
|
|
||||||
|
|
||||||
bind( type<void>(), &X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8 )();
|
|
||||||
bind( type<void>(), &X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8 )();
|
|
||||||
bind( type<void>(), &X::g8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8 )();
|
|
||||||
|
|
||||||
BOOST_TEST( x.hash == 23558 );
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
member_function_test();
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
#include <boost/config.hpp>
|
|
||||||
|
|
||||||
#if defined( BOOST_MSVC )
|
|
||||||
|
|
||||||
#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_placeholder_test.cpp - test custom placeholders
|
|
||||||
//
|
|
||||||
// Copyright (c) 2006 Peter Dimov
|
|
||||||
//
|
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
|
||||||
//
|
|
||||||
// See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
long f( 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
template< int I > struct custom_placeholder
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace boost
|
|
||||||
{
|
|
||||||
|
|
||||||
template< int I > struct is_placeholder< custom_placeholder< I > >
|
|
||||||
{
|
|
||||||
enum { value = I };
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int const x1 = 1;
|
|
||||||
int const x2 = 2;
|
|
||||||
int const x3 = 3;
|
|
||||||
int const x4 = 4;
|
|
||||||
int const x5 = 5;
|
|
||||||
int const x6 = 6;
|
|
||||||
int const x7 = 7;
|
|
||||||
int const x8 = 8;
|
|
||||||
int const x9 = 9;
|
|
||||||
|
|
||||||
custom_placeholder<1> p1;
|
|
||||||
custom_placeholder<2> p2;
|
|
||||||
custom_placeholder<3> p3;
|
|
||||||
custom_placeholder<4> p4;
|
|
||||||
custom_placeholder<5> p5;
|
|
||||||
custom_placeholder<6> p6;
|
|
||||||
custom_placeholder<7> p7;
|
|
||||||
custom_placeholder<8> p8;
|
|
||||||
custom_placeholder<9> p9;
|
|
||||||
|
|
||||||
BOOST_TEST(
|
|
||||||
boost::bind( f, p1, p2, p3, p4, p5, p6, p7, p8, p9 )
|
|
||||||
( x1, x2, x3, x4, x5, x6, x7, x8, x9 ) == 987654321L );
|
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
#include <boost/config.hpp>
|
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
|
||||||
#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_rv_sp_test.cpp - smart pointer returned by value from an inner bind
|
|
||||||
//
|
|
||||||
// Copyright (c) 2005 Peter Dimov
|
|
||||||
//
|
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See
|
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
|
|
||||||
struct X
|
|
||||||
{
|
|
||||||
int v_;
|
|
||||||
|
|
||||||
X( int v ): v_( v )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int f()
|
|
||||||
{
|
|
||||||
return v_;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Y
|
|
||||||
{
|
|
||||||
boost::shared_ptr<X> f()
|
|
||||||
{
|
|
||||||
return boost::shared_ptr<X>( new X( 42 ) );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
Y y;
|
|
||||||
|
|
||||||
BOOST_TEST( boost::bind( &X::f, boost::bind( &Y::f, &y ) )() == 42 );
|
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
#include <boost/config.hpp>
|
|
||||||
|
|
||||||
#if defined( BOOST_MSVC )
|
|
||||||
|
|
||||||
#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_rvalue_test.cpp
|
|
||||||
//
|
|
||||||
// Copyright (c) 2006 Peter Dimov
|
|
||||||
//
|
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
|
||||||
//
|
|
||||||
// See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
int f( int x )
|
|
||||||
{
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
BOOST_TEST(
|
|
||||||
boost::bind( f, _1 )
|
|
||||||
( 1 ) == 1 );
|
|
||||||
|
|
||||||
BOOST_TEST(
|
|
||||||
boost::bind( f, _2 )
|
|
||||||
( 1, 2 ) == 2 );
|
|
||||||
|
|
||||||
BOOST_TEST(
|
|
||||||
boost::bind( f, _3 )
|
|
||||||
( 1, 2, 3 ) == 3 );
|
|
||||||
|
|
||||||
BOOST_TEST(
|
|
||||||
boost::bind( f, _4 )
|
|
||||||
( 1, 2, 3, 4 ) == 4 );
|
|
||||||
|
|
||||||
BOOST_TEST(
|
|
||||||
boost::bind( f, _5 )
|
|
||||||
( 1, 2, 3, 4, 5 ) == 5 );
|
|
||||||
|
|
||||||
BOOST_TEST(
|
|
||||||
boost::bind( f, _6 )
|
|
||||||
( 1, 2, 3, 4, 5, 6 ) == 6 );
|
|
||||||
|
|
||||||
BOOST_TEST(
|
|
||||||
boost::bind( f, _7 )
|
|
||||||
( 1, 2, 3, 4, 5, 6, 7 ) == 7 );
|
|
||||||
|
|
||||||
BOOST_TEST(
|
|
||||||
boost::bind( f, _8 )
|
|
||||||
( 1, 2, 3, 4, 5, 6, 7, 8 ) == 8 );
|
|
||||||
|
|
||||||
BOOST_TEST(
|
|
||||||
boost::bind( f, _9 )
|
|
||||||
( 1, 2, 3, 4, 5, 6, 7, 8, 9 ) == 9 );
|
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
|
||||||
@@ -1,147 +0,0 @@
|
|||||||
#include <boost/config.hpp>
|
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
|
||||||
#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_unary_addr.cpp
|
|
||||||
//
|
|
||||||
// Copyright (c) 2005 Peter Dimov
|
|
||||||
//
|
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See
|
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
class X
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
void operator& ();
|
|
||||||
void operator& () const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void operator()()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()() const
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()(int)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()(int) const
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()(int, int)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()(int, int) const
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()(int, int, int)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()(int, int, int) const
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()(int, int, int, int)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()(int, int, int, int) const
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()(int, int, int, int, int)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()(int, int, int, int, int) const
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()(int, int, int, int, int, int)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()(int, int, int, int, int, int) const
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()(int, int, int, int, int, int, int)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()(int, int, int, int, int, int, int) const
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()(int, int, int, int, int, int, int, int)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()(int, int, int, int, int, int, int, int) const
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()(int, int, int, int, int, int, int, int, int)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()(int, int, int, int, int, int, int, int, int) const
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class F> void test_const( F const & f )
|
|
||||||
{
|
|
||||||
f();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class F> void test( F f )
|
|
||||||
{
|
|
||||||
f();
|
|
||||||
test_const( f );
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
test( boost::bind<void>( X() ) );
|
|
||||||
test( boost::bind<void>( X(), 1 ) );
|
|
||||||
test( boost::bind<void>( X(), 1, 2 ) );
|
|
||||||
test( boost::bind<void>( X(), 1, 2, 3 ) );
|
|
||||||
test( boost::bind<void>( X(), 1, 2, 3, 4 ) );
|
|
||||||
test( boost::bind<void>( X(), 1, 2, 3, 4, 5 ) );
|
|
||||||
test( boost::bind<void>( X(), 1, 2, 3, 4, 5, 6 ) );
|
|
||||||
test( boost::bind<void>( X(), 1, 2, 3, 4, 5, 6, 7 ) );
|
|
||||||
test( boost::bind<void>( X(), 1, 2, 3, 4, 5, 6, 7, 8 ) );
|
|
||||||
test( boost::bind<void>( X(), 1, 2, 3, 4, 5, 6, 7, 8, 9 ) );
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
#include <boost/config.hpp>
|
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
|
||||||
# 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
|
|
||||||
|
|
||||||
// Copyright (c) 2006 Douglas Gregor <doug.gregor@gmail.com>
|
|
||||||
// Copyright (c) 2006 Peter Dimov
|
|
||||||
//
|
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See
|
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
|
||||||
#include <boost/visit_each.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
|
|
||||||
|
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
|
||||||
|
|
||||||
struct visitor
|
|
||||||
{
|
|
||||||
int hash;
|
|
||||||
|
|
||||||
visitor(): hash( 0 )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T> void operator()( T const & t )
|
|
||||||
{
|
|
||||||
std::cout << "visitor::operator()( T ): " << typeid( t ).name() << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()( int const & t )
|
|
||||||
{
|
|
||||||
std::cout << "visitor::operator()( int ): " << t << std::endl;
|
|
||||||
hash = hash * 10 + t;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
int f( int x, int y, int z )
|
|
||||||
{
|
|
||||||
return x + y + z;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
visitor vis;
|
|
||||||
|
|
||||||
boost::visit_each( vis, boost::bind( f, 3, _1, 4 ) );
|
|
||||||
|
|
||||||
BOOST_TEST( vis.hash == 34 );
|
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
#include <boost/config.hpp>
|
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
|
||||||
#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_test.cpp - mem_fn.hpp with rvalues
|
|
||||||
//
|
|
||||||
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
|
||||||
// Copyright (c) 2005 Peter Dimov
|
|
||||||
//
|
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See
|
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
unsigned int hash = 0;
|
|
||||||
|
|
||||||
struct X
|
|
||||||
{
|
|
||||||
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; }
|
|
||||||
};
|
|
||||||
|
|
||||||
int detect_errors(bool x)
|
|
||||||
{
|
|
||||||
if( x )
|
|
||||||
{
|
|
||||||
std::cerr << "no errors detected.\n";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cerr << "test failed.\n";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boost::shared_ptr<X> make()
|
|
||||||
{
|
|
||||||
return boost::shared_ptr<X>( new X );
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
using boost::mem_fn;
|
|
||||||
|
|
||||||
mem_fn(&X::f0)( make() );
|
|
||||||
mem_fn(&X::g0)( make() );
|
|
||||||
|
|
||||||
mem_fn(&X::f1)( make(), 1 );
|
|
||||||
mem_fn(&X::g1)( make(), 1 );
|
|
||||||
|
|
||||||
mem_fn(&X::f2)( make(), 1, 2 );
|
|
||||||
mem_fn(&X::g2)( make(), 1, 2 );
|
|
||||||
|
|
||||||
mem_fn(&X::f3)( make(), 1, 2, 3 );
|
|
||||||
mem_fn(&X::g3)( make(), 1, 2, 3 );
|
|
||||||
|
|
||||||
mem_fn(&X::f4)( make(), 1, 2, 3, 4 );
|
|
||||||
mem_fn(&X::g4)( make(), 1, 2, 3, 4 );
|
|
||||||
|
|
||||||
mem_fn(&X::f5)( make(), 1, 2, 3, 4, 5 );
|
|
||||||
mem_fn(&X::g5)( make(), 1, 2, 3, 4, 5 );
|
|
||||||
|
|
||||||
mem_fn(&X::f6)( make(), 1, 2, 3, 4, 5, 6 );
|
|
||||||
mem_fn(&X::g6)( make(), 1, 2, 3, 4, 5, 6 );
|
|
||||||
|
|
||||||
mem_fn(&X::f7)( make(), 1, 2, 3, 4, 5, 6, 7 );
|
|
||||||
mem_fn(&X::g7)( make(), 1, 2, 3, 4, 5, 6, 7 );
|
|
||||||
|
|
||||||
mem_fn(&X::f8)( make(), 1, 2, 3, 4, 5, 6, 7, 8 );
|
|
||||||
mem_fn(&X::g8)( make(), 1, 2, 3, 4, 5, 6, 7, 8 );
|
|
||||||
|
|
||||||
return detect_errors( hash == 2155 );
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
#include <boost/config.hpp>
|
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
|
||||||
#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
|
|
||||||
|
|
||||||
// ref_fn_test.cpp: ref( f )
|
|
||||||
//
|
|
||||||
// Copyright (c) 2008 Peter Dimov
|
|
||||||
//
|
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
|
||||||
// See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt
|
|
||||||
|
|
||||||
#include <boost/ref.hpp>
|
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
void f0()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void f1(int)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void f2(int, int)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void f3(int, int, int)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void f4(int, int, int, int)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void f5(int, int, int, int, int)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void f6(int, int, int, int, int, int)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void f7(int, int, int, int, int, int, int)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void f8(int, int, int, int, int, int, int, int)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void f9(int, int, int, int, int, int, int, int, int)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#define BOOST_TEST_REF( f ) BOOST_TEST( &boost::ref( f ).get() == &f )
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int v = 0;
|
|
||||||
BOOST_TEST_REF( v );
|
|
||||||
|
|
||||||
BOOST_TEST_REF( f0 );
|
|
||||||
BOOST_TEST_REF( f1 );
|
|
||||||
BOOST_TEST_REF( f2 );
|
|
||||||
BOOST_TEST_REF( f3 );
|
|
||||||
BOOST_TEST_REF( f4 );
|
|
||||||
BOOST_TEST_REF( f5 );
|
|
||||||
BOOST_TEST_REF( f6 );
|
|
||||||
BOOST_TEST_REF( f7 );
|
|
||||||
BOOST_TEST_REF( f8 );
|
|
||||||
BOOST_TEST_REF( f9 );
|
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user