mirror of
https://github.com/boostorg/bind.git
synced 2026-04-13 13:15:50 +02:00
Compare commits
75 Commits
boost-1.32
...
boost-1.55
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65188d097e | ||
|
|
fa8debfc80 | ||
|
|
c53ba15ce5 | ||
|
|
7b89dd7fd9 | ||
|
|
787d3cb7b4 | ||
|
|
6e208277e3 | ||
|
|
70f0c8efbb | ||
|
|
00b3c895fd | ||
|
|
8b58b0d207 | ||
|
|
961c3c5fa9 | ||
|
|
c0d14f5e7c | ||
|
|
52d9c13d6e | ||
|
|
a060765e8b | ||
|
|
7e1ad242f9 | ||
|
|
a5f729bbeb | ||
|
|
6431906dcc | ||
|
|
18b0dd3e17 | ||
|
|
465899b2ac | ||
|
|
8f507b9aec | ||
|
|
387e536a0a | ||
|
|
85d146117e | ||
|
|
45720b6f2d | ||
|
|
e22e641bbf | ||
|
|
224e9f5eec | ||
|
|
1943ac521b | ||
|
|
77d2c4bab1 | ||
|
|
41a2e80197 | ||
|
|
9ea5cf40da | ||
|
|
4d1f7d0411 | ||
|
|
967e9af0eb | ||
|
|
c5396f02c6 | ||
|
|
e8646fa260 | ||
|
|
a87638486b | ||
|
|
472f9e6ebe | ||
|
|
d43950f1a6 | ||
|
|
f57cb48b9f | ||
|
|
03bb04bb85 | ||
|
|
bba3d96bda | ||
|
|
cb2cca146f | ||
|
|
3304c00da3 | ||
|
|
3e980f8c34 | ||
|
|
42efa96a2f | ||
|
|
d90c96a7e4 | ||
|
|
d28a5cc23a | ||
|
|
98daeb3ad5 | ||
|
|
35b98458a1 | ||
|
|
2d6ccb09a7 | ||
|
|
a9deb8c577 | ||
|
|
840b39144c | ||
|
|
e5a60bfe1c | ||
|
|
5fbb6558ec | ||
|
|
3b89e4215b | ||
|
|
efc36ff07b | ||
|
|
b85adc3a58 | ||
|
|
0c96dbe3f1 | ||
|
|
2a21f7df2c | ||
|
|
9cfe194f80 | ||
|
|
66ed4fc9e1 | ||
|
|
23b64e1358 | ||
|
|
0aa407e77d | ||
|
|
27d1cf539b | ||
|
|
c7710aad38 | ||
|
|
4a1c4894c7 | ||
|
|
9f0a516068 | ||
|
|
6602068638 | ||
|
|
c25b216898 | ||
|
|
ed817c5b15 | ||
|
|
7b9a97a758 | ||
|
|
b1f05e7268 | ||
|
|
28cb8f8206 | ||
|
|
ccd0394b86 | ||
|
|
ee5ab38a63 | ||
|
|
35a2d208d5 | ||
|
|
424480e55b | ||
|
|
094d43c6e8 |
252
bind.html
252
bind.html
@@ -7,9 +7,9 @@
|
||||
<body style="MARGIN-LEFT: 5%; MARGIN-RIGHT: 5%" bgColor="white">
|
||||
<table width="100%" border="0">
|
||||
<tr>
|
||||
<td width="277"><IMG height="86" alt="boost.png (6897 bytes)" src="../../boost.png" width="277">
|
||||
<td width="277"><A href="../../index.htm"><IMG height="86" alt="boost.png (6897 bytes)" src="../../boost.png" width="277" border="0"></A>
|
||||
</td>
|
||||
<td align="middle">
|
||||
<td align="center">
|
||||
<h1>bind.hpp</h1>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -27,6 +27,7 @@
|
||||
to members</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#nested_binds">Using nested binds for function
|
||||
composition</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>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#with_algorithms">Using bind with standard
|
||||
algorithms</A></h4>
|
||||
@@ -59,6 +60,8 @@
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_long_form">Inappropriate use of
|
||||
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_overloaded">Binding an overloaded function</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_modeling_stl_function_object_concepts">Modeling STL function object concepts</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_const_arg"><b>const</b> in signatures</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_msvc_using">MSVC specific: using
|
||||
boost::bind;</A></h4>
|
||||
@@ -76,8 +79,8 @@
|
||||
<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", "__fastcall", and
|
||||
"pascal" Support</A></h4>
|
||||
<h4 style="MARGIN-LEFT: 40pt"><A href="#stdcall">"__stdcall", "__cdecl", "__fastcall",
|
||||
and "pascal" 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>
|
||||
<h2><a name="Purpose">Purpose</a></h2>
|
||||
@@ -151,6 +154,8 @@ bind(f, i, _1);
|
||||
<pre>int i = 5;
|
||||
|
||||
bind(f, ref(i), _1);
|
||||
|
||||
bind(f, cref(42), _1);
|
||||
</pre>
|
||||
<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.
|
||||
@@ -185,6 +190,27 @@ bind(std::less<int>(), _1, 9)(x); // x < 9
|
||||
</pre>
|
||||
<p>[Note: the ability to omit the return type is not available on all compilers.]
|
||||
</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>
|
||||
<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>
|
||||
@@ -192,14 +218,14 @@ bind(std::less<int>(), _1, 9)(x); // x < 9
|
||||
boost::mem_fn</A> has been used to convert the member pointer into a
|
||||
function object. In other words, the expression
|
||||
</p>
|
||||
<pre>bind(&X::f, <i>args</I>)
|
||||
<pre>bind(&X::f, <i>args</i>)
|
||||
</pre>
|
||||
<p>is equivalent to
|
||||
</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>
|
||||
<p>where <b>R</b> is the return type of <b>X::f</b> (for member functions) or a
|
||||
const reference to the type of the member (for data members.)
|
||||
<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.)
|
||||
</p>
|
||||
<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
|
||||
@@ -220,8 +246,8 @@ int i = 5;
|
||||
|
||||
bind(&X::f, ref(x), _1)(i); // x.f(i)
|
||||
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, p, _1)(i); // (<i>internal copy of p</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)
|
||||
</pre>
|
||||
<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,
|
||||
@@ -270,15 +296,40 @@ std::vector<pf> v;
|
||||
|
||||
std::for_each(v.begin(), v.end(), bind(apply<void>(), _1, 5));
|
||||
</pre>
|
||||
<P>Sometimes it is necessary not to evaluate the first argument, but <STRONG>not</STRONG>
|
||||
to evaluate some of the other arguments, even when they are nested <STRONG>bind</STRONG>
|
||||
subexpressions. This can 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 evaluate it. When called, <STRONG>protect</STRONG> simply
|
||||
forwards the argument list to the other function object unmodified.</P>
|
||||
<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
|
||||
first, even when they are nested <STRONG>bind</STRONG> subexpressions. This can
|
||||
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
|
||||
evaluate it. When called, <STRONG>protect</STRONG> simply forwards the argument
|
||||
list to the other function object unmodified.</P>
|
||||
<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
|
||||
evaluation, use <tt>protect(bind(f, ...))</tt>.</P>
|
||||
<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
|
||||
logical not operator <code>!</code> and the relational and logical operators <code>==</code>,
|
||||
<code>!=</code>, <code><</code>, <code><=</code>, <code>></code>, <code>>=</code>,
|
||||
<code>&&</code>, <code>||</code>.</p>
|
||||
<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
|
||||
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
|
||||
logical operator, is equivalent to <tt>bind( <EM>relation</EM>(), bind(f, ...), x )</tt>,
|
||||
where <em>relation</em> is a function object that takes two arguments <tt>a</tt>
|
||||
and <tt>b</tt> and 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><tt>std::remove_if( first, last, !bind( &X::visible, _1 ) ); // remove invisible
|
||||
objects</tt></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" || bind(
|
||||
&X::name, _1 ) == "Paul" );</tt></P>
|
||||
<P>against a placeholder:</P>
|
||||
<P><tt>bind( &X::name, _1 ) == _2</tt></P>
|
||||
<P>or against another <tt>bind</tt> expression:</P>
|
||||
<P><tt>std::sort( first, last, bind( &X::name, _1 ) < bind( &X::name, _2 )
|
||||
); // sort by name</tt></P>
|
||||
<h2><a name="Examples">Examples</a></h2>
|
||||
<h3><a name="with_algorithms">Using bind with standard algorithms</a></h3>
|
||||
<pre>class image;
|
||||
@@ -315,7 +366,7 @@ void render(image & target)
|
||||
{
|
||||
public:
|
||||
|
||||
<A href="../function/index.html" >boost::function</A><void> onClick;
|
||||
<A href="../function/index.html" >boost::function</A><void()> onClick;
|
||||
};
|
||||
|
||||
class player
|
||||
@@ -336,10 +387,12 @@ void connect()
|
||||
}
|
||||
</pre>
|
||||
<h2><a name="Limitations">Limitations</a></h2>
|
||||
<p>The function objects generated by <b>bind</b> take their arguments by reference
|
||||
and cannot, therefore, accept non-const temporaries or literal constants. This
|
||||
is an inherent limitation of the C++ language, known as <A href="http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm">
|
||||
the forwarding problem</A>.</p>
|
||||
<p>As a general rule, the function objects generated by <b>bind</b> take their
|
||||
arguments by reference and cannot, therefore, accept non-const temporaries or
|
||||
literal constants. This is an inherent limitation of the C++ language in its
|
||||
current (2003) incarnation, known as <A href="http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm">
|
||||
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>
|
||||
<pre>template<class T> void f(T & t);
|
||||
@@ -347,17 +400,17 @@ void connect()
|
||||
<p>to accept arguments of arbitrary types and pass them on unmodified. As noted,
|
||||
this does not work with non-const r-values.
|
||||
</p>
|
||||
<p>An oft-proposed "solution" to this problem is to add an overload:
|
||||
<p>On compilers that support partial ordering of function templates, a possible
|
||||
solution is to add an overload:
|
||||
</p>
|
||||
<pre>template<class T> void f(T & t);
|
||||
template<class T> void f(T const & t);
|
||||
</pre>
|
||||
<p>Unfortunately, this (a) requires providing 512 overloads for nine arguments and
|
||||
(b) does not actually work for const arguments, both l- and r-values, since the
|
||||
two templates produce the exact same signature and cannot be partially ordered.
|
||||
</p>
|
||||
<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>Unfortunately, this requires providing 512 overloads for nine arguments, which
|
||||
is impractical. The library chooses a small subset: for up to two arguments, it
|
||||
provides the const overloads in full, for arities of three and more it provides
|
||||
a single additional overload with all of the arguments taken by const
|
||||
reference. This covers a reasonable portion of the use cases.
|
||||
</p>
|
||||
<h2><a name="FAQ">Frequently Asked Questions</a></h2>
|
||||
<h3><a name="Q_doesnt_compile">Why doesn't this compile?</a></h3>
|
||||
@@ -436,7 +489,7 @@ int main()
|
||||
int main()
|
||||
{
|
||||
boost::bind(&X::f, 1); // error, X::f takes two arguments
|
||||
boost::bind(&X::f, <b>_1</B>, 1); // OK
|
||||
boost::bind(&X::f, <b>_1</b>, 1); // OK
|
||||
}
|
||||
</pre>
|
||||
<h3><a name="err_signature">The function object cannot be called with the specified
|
||||
@@ -502,6 +555,79 @@ int main()
|
||||
recognized by the short form of bind.
|
||||
</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_modeling_stl_function_object_concepts">Modeling STL function object concepts</a></h3>
|
||||
<p>The function objects that are produced by <b>boost::bind</b> do not model the
|
||||
STL <a href="http://www.sgi.com/tech/stl/UnaryFunction.html">Unary Function</a> or
|
||||
<a href="http://www.sgi.com/tech/stl/BinaryFunction.html">Binary Function</a> concepts,
|
||||
even when the function objects are unary or binary operations, because the function object
|
||||
types are missing public typedefs <tt>result_type</tt> and <tt>argument_type</tt> or
|
||||
<tt>first_argument_type</tt> and <tt>second_argument_type</tt>. In cases where these
|
||||
typedefs are desirable, however, the utility function <tt>make_adaptable</tt>
|
||||
can be used to adapt unary and binary function objects to these concepts. This allows
|
||||
unary and binary function objects resulting from <b>boost::bind</b> to be combined with
|
||||
STL templates such as <a href="http://msdn.microsoft.com/en-us/library/se0409db%28v=VS.90%29.aspx"><tt>std::unary_negate</tt></a>
|
||||
and <a href="http://msdn.microsoft.com/en-us/library/833073z4%28v=VS.90%29.aspx"><tt>std::binary_negate</tt></a>.</p>
|
||||
|
||||
<p>The <tt>make_adaptable</tt> function is defined in <<a href="../../boost/bind/make_adaptable.hpp">boost/bind/make_adaptable.hpp</a>>,
|
||||
which must be included explicitly in addition to <boost/bind.hpp>:</p>
|
||||
<pre>
|
||||
#include <boost/bind/make_adaptable.hpp>
|
||||
|
||||
template <class R, class F> <i>unspecified-type</i> make_adaptable(F f);
|
||||
|
||||
template<class R, class A1, class F> <i>unspecified-unary-functional-type</i> make_adaptable(F f);
|
||||
|
||||
template<class R, class A1, class A2, class F> <i>unspecified-binary-functional-type</i> make_adaptable(F f);
|
||||
|
||||
template<class R, class A1, class A2, class A3, class F> <i>unspecified-ternary-functional-type</i> make_adaptable(F f);
|
||||
|
||||
template<class R, class A1, class A2, class A3, class A4, class F> <i>unspecified-4-ary-functional-type</i> make_adaptable(F f);
|
||||
</pre>
|
||||
|
||||
<p>This example shows how to use <tt>make_adaptable</tt> to make a predicate for "is not a space":</p>
|
||||
<pre>typedef char char_t;
|
||||
std::locale loc("");
|
||||
const std::ctype<char_t>& ct = std::use_facet<std::ctype<char_t> >(loc);
|
||||
|
||||
auto isntspace = std::not1( boost::make_adaptable<bool, char_t>( boost::bind(&std::ctype<char_t>::is, &ct, std::ctype_base::space, _1) ) );
|
||||
</pre>
|
||||
|
||||
<p>In this example, <b>boost::bind</b> creates the "is a space" (unary) predicate.
|
||||
It is then passed to <tt>make_adaptable</tt> so that a function object modeling
|
||||
the Unary Function concept can be created, serving as the argument to
|
||||
<a href="http://msdn.microsoft.com/en-us/library/syyszzf8%28v=VS.90%29.aspx"><tt>std::not1</tt></a>.</p>
|
||||
|
||||
<h3><a name="err_const_arg"><b>const</b> in signatures</a></h3>
|
||||
<p>Some compilers, including MSVC 6.0 and Borland C++ 5.5.1, have problems with the
|
||||
top-level <b>const</b> in function signatures:
|
||||
@@ -552,37 +678,37 @@ int main()
|
||||
|
||||
// no arguments
|
||||
|
||||
template<class R, class F> <i>unspecified-1</I> <A href="#bind_1" >bind</A>(F f);
|
||||
template<class R, class F> <i>unspecified-1</i> <A href="#bind_1" >bind</A>(F f);
|
||||
|
||||
template<class F> <i>unspecified-1-1</I> <A href="#bind_1_1" >bind</A>(F f);
|
||||
template<class F> <i>unspecified-1-1</i> <A href="#bind_1_1" >bind</A>(F f);
|
||||
|
||||
template<class R> <i>unspecified-2</I> <A href="#bind_2" >bind</A>(R (*f) ());
|
||||
template<class R> <i>unspecified-2</i> <A href="#bind_2" >bind</A>(R (*f) ());
|
||||
|
||||
// one argument
|
||||
|
||||
template<class R, class F, class A1> <i>unspecified-3</I> <A href="#bind_3" >bind</A>(F f, A1 a1);
|
||||
template<class R, class F, class A1> <i>unspecified-3</i> <A href="#bind_3" >bind</A>(F f, A1 a1);
|
||||
|
||||
template<class F, class A1> <i>unspecified-3-1</I> <A href="#bind_3_1" >bind</A>(F f, A1 a1);
|
||||
template<class F, class A1> <i>unspecified-3-1</i> <A href="#bind_3_1" >bind</A>(F f, A1 a1);
|
||||
|
||||
template<class R, class B1, class A1> <i>unspecified-4</I> <A href="#bind_4" >bind</A>(R (*f) (B1), A1 a1);
|
||||
template<class R, class B1, class A1> <i>unspecified-4</i> <A href="#bind_4" >bind</A>(R (*f) (B1), A1 a1);
|
||||
|
||||
template<class R, class T, class A1> <i>unspecified-5</I> <A href="#bind_5" >bind</A>(R (T::*f) (), A1 a1);
|
||||
template<class R, class T, class A1> <i>unspecified-5</i> <A href="#bind_5" >bind</A>(R (T::*f) (), A1 a1);
|
||||
|
||||
template<class R, class T, class A1> <i>unspecified-6</I> <A href="#bind_6" >bind</A>(R (T::*f) () const, A1 a1);
|
||||
template<class R, class T, class A1> <i>unspecified-6</i> <A href="#bind_6" >bind</A>(R (T::*f) () const, A1 a1);
|
||||
|
||||
template<class R, class T, class A1> <i>unspecified-6-1</I> <A href="#bind_6_1" >bind</A>(R T::*f, A1 a1);
|
||||
template<class R, class T, class A1> <i>unspecified-6-1</i> <A href="#bind_6_1" >bind</A>(R T::*f, A1 a1);
|
||||
|
||||
// two arguments
|
||||
|
||||
template<class R, class F, class A1, class A2> <i>unspecified-7</I> <A href="#bind_7" >bind</A>(F f, A1 a1, A2 a2);
|
||||
template<class R, class F, class A1, class A2> <i>unspecified-7</i> <A href="#bind_7" >bind</A>(F f, A1 a1, A2 a2);
|
||||
|
||||
template<class F, class A1, class A2> <i>unspecified-7-1</I> <A href="#bind_7_1" >bind</A>(F f, A1 a1, A2 a2);
|
||||
template<class F, class A1, class A2> <i>unspecified-7-1</i> <A href="#bind_7_1" >bind</A>(F f, A1 a1, A2 a2);
|
||||
|
||||
template<class R, class B1, class B2, class A1, class A2> <i>unspecified-8</I> <A href="#bind_8" >bind</A>(R (*f) (B1, B2), A1 a1, A2 a2);
|
||||
template<class R, class B1, class B2, class A1, class A2> <i>unspecified-8</i> <A href="#bind_8" >bind</A>(R (*f) (B1, B2), A1 a1, A2 a2);
|
||||
|
||||
template<class R, class T, class B1, class A1, class A2> <i>unspecified-9</I> <A href="#bind_9" >bind</A>(R (T::*f) (B1), A1 a1, A2 a2);
|
||||
template<class R, class T, class B1, class A1, class A2> <i>unspecified-9</i> <A href="#bind_9" >bind</A>(R (T::*f) (B1), A1 a1, A2 a2);
|
||||
|
||||
template<class R, class T, class B1, class A1, class A2> <i>unspecified-10</I> <A href="#bind_10" >bind</A>(R (T::*f) (B1) const, A1 a1, A2 a2);
|
||||
template<class R, class T, class B1, class A1, class A2> <i>unspecified-10</i> <A href="#bind_10" >bind</A>(R (T::*f) (B1) const, A1 a1, A2 a2);
|
||||
|
||||
// implementation defined number of additional overloads for more arguments
|
||||
|
||||
@@ -591,11 +717,11 @@ template<class R, class T, class B1, class A1, class A2> <i>unspecified-10
|
||||
namespace
|
||||
{
|
||||
|
||||
<i>unspecified-placeholder-type-1</I> _1;
|
||||
<i>unspecified-placeholder-type-1</i> _1;
|
||||
|
||||
<i>unspecified-placeholder-type-2</I> _2;
|
||||
<i>unspecified-placeholder-type-2</i> _2;
|
||||
|
||||
<i>unspecified-placeholder-type-3</I> _3;
|
||||
<i>unspecified-placeholder-type-3</i> _3;
|
||||
|
||||
// implementation defined number of additional placeholder definitions
|
||||
|
||||
@@ -683,7 +809,7 @@ namespace
|
||||
<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>
|
||||
<blockquote>
|
||||
<p><b>Effects:</b> Equivalent to <tt>bind<R const &>(<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>
|
||||
</blockquote>
|
||||
<h4><a name="bind_7">template<class R, class F, class A1, class A2> <i>unspecified-7</i>
|
||||
@@ -784,18 +910,18 @@ namespace
|
||||
<h3><a name="Dependencies">Dependencies</a></h3>
|
||||
<ul>
|
||||
<li>
|
||||
<A href="../config/config.htm">Boost.Config</A></li>
|
||||
<A href="../config/config.htm">Boost.Config</A>
|
||||
<li>
|
||||
<A href="ref.html">boost/ref.hpp</A></li>
|
||||
<A href="ref.html">boost/ref.hpp</A>
|
||||
<li>
|
||||
<A href="mem_fn.html">boost/mem_fn.hpp</A></li>
|
||||
<A href="mem_fn.html">boost/mem_fn.hpp</A>
|
||||
<li>
|
||||
<A href="../../boost/type.hpp">boost/type.hpp</A></li>
|
||||
</ul>
|
||||
<h3><a name="NumberOfArguments">Number of Arguments</a></h3>
|
||||
<p>This implementation supports function objects with up to nine arguments. This is
|
||||
an implementation detail, not an inherent limitation of the design.</p>
|
||||
<h3><a name="stdcall">"__stdcall", "__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
|
||||
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
|
||||
@@ -813,6 +939,12 @@ namespace
|
||||
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>
|
||||
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
|
||||
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
|
||||
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
|
||||
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: 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>
|
||||
@@ -826,11 +958,12 @@ namespace
|
||||
The <a href="http://staff.cs.utu.fi/BL/">Binder Library</a>
|
||||
by Jaakko Järvi;
|
||||
<li>
|
||||
The <a href="../lambda/">Lambda Library</a> (now part of Boost)
|
||||
by Jaakko Järvi and Gary Powell (the successor to the Binder Library);
|
||||
The <a href="../lambda/index.html">Lambda Library</a>
|
||||
(now part of Boost) by Jaakko Järvi and Gary Powell (the successor to the
|
||||
Binder Library);
|
||||
<li>
|
||||
<a href="http://matfys.lth.se/~petter/src/more/stlext/index.html">Extensions to the
|
||||
STL</a> by Petter Urkedal.</li></ul>
|
||||
<a href="http://more.sourceforge.net/">Extensions to the STL</a> by Petter
|
||||
Urkedal.</li></ul>
|
||||
<p>Doug Gregor suggested that a visitor mechanism would allow <b>bind</b> to
|
||||
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">
|
||||
@@ -856,10 +989,9 @@ namespace
|
||||
<p><br>
|
||||
<br>
|
||||
<br>
|
||||
<small>Copyright © 2001, 2002 by Peter Dimov and Multi Media Ltd. Permission to
|
||||
copy, use, modify, sell and distribute this document is granted provided this
|
||||
copyright notice appears in all copies. This document is provided "as is"
|
||||
without express or implied warranty, and with no claim as to its suitability
|
||||
for any purpose.</small></p>
|
||||
<small>Copyright © 2001, 2002 by Peter Dimov and Multi Media Ltd. Copyright
|
||||
2003-2008 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>
|
||||
|
||||
@@ -31,32 +31,18 @@
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
// default implementation of visit_each
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template<class V, class T> void visit_each(V & v, T const & t, long)
|
||||
{
|
||||
v(t, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// visitor
|
||||
|
||||
int hash = 0;
|
||||
//
|
||||
|
||||
struct visitor
|
||||
{
|
||||
template<class T> void operator()(boost::reference_wrapper<T> const & r, int) const
|
||||
template<class T> void operator()( boost::reference_wrapper<T> const & r ) const
|
||||
{
|
||||
std::cout << "Reference to " << typeid(T).name() << " @ " << &r.get() << " (with value " << r.get() << ")\n";
|
||||
hash += r.get();
|
||||
}
|
||||
|
||||
template<class T> void operator()(T const &, long) const
|
||||
template<class T> void operator()( T const & t ) const
|
||||
{
|
||||
std::cout << "Value of type " << typeid(T).name() << '\n';
|
||||
++hash;
|
||||
std::cout << "Value of type " << typeid(T).name() << " (with value " << t << ")\n";
|
||||
}
|
||||
};
|
||||
|
||||
@@ -70,26 +56,10 @@ int f(int & i, int & j, int)
|
||||
int x = 2;
|
||||
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()
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
visitor v;
|
||||
visit_each(v, bind<int>(bind(f, ref(x), _1, 42), ref(y)), 0);
|
||||
|
||||
return detect_errors(hash == 12);
|
||||
}
|
||||
|
||||
14
doc/Jamfile.v2
Normal file
14
doc/Jamfile.v2
Normal file
@@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2002 Douglas Gregor <doug.gregor -at- gmail.com>
|
||||
|
||||
# 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)
|
||||
project boost/doc ;
|
||||
import boostbook : boostbook ;
|
||||
|
||||
boostbook ref-doc : ref.xml
|
||||
:
|
||||
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html
|
||||
<xsl:param>boost.root=../../../..
|
||||
;
|
||||
|
||||
38
doc/ref.xml
38
doc/ref.xml
@@ -38,11 +38,9 @@
|
||||
</copyright>
|
||||
|
||||
<legalnotice>
|
||||
<para>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.
|
||||
<para>Subject to the Boost Software License, Version 1.0. See
|
||||
accompanying file <filename>LICENSE_1_0.txt</filename> or copy at
|
||||
<ulink url="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</ulink>.
|
||||
</para>
|
||||
</legalnotice>
|
||||
|
||||
@@ -61,10 +59,13 @@
|
||||
references to function templates (algorithms) that would usually
|
||||
take copies of their arguments. It defines the class template
|
||||
<code><classname>boost::reference_wrapper<T></classname></code>,
|
||||
the two functions
|
||||
two functions
|
||||
<code><functionname>boost::ref</functionname></code> and
|
||||
<code><functionname>boost::cref</functionname></code> that return
|
||||
instances of <code>boost::reference_wrapper<T></code>, and the
|
||||
instances of <code>boost::reference_wrapper<T></code>,
|
||||
a function <code><functionname>boost::unwrap_ref</functionname></code>
|
||||
that unwraps a <code>boost::reference_wrapper<T></code> or
|
||||
returns a reference to any other type of object, and the
|
||||
two traits classes
|
||||
<code><classname>boost::is_reference_wrapper<T></classname></code>
|
||||
and
|
||||
@@ -92,6 +93,11 @@
|
||||
<code>boost::cref(x)</code> returns a
|
||||
<code>boost::reference_wrapper<X const>(x)</code>.</para>
|
||||
|
||||
<para>The expression <code>boost::unwrap_ref(x)</code>
|
||||
returns a
|
||||
<code>boost::unwrap_reference<X>::type&</code> where X
|
||||
is the type of x.</para>
|
||||
|
||||
<para>The expression
|
||||
<code>boost::is_reference_wrapper<T>::value</code>
|
||||
is true if T is a <code>reference_wrapper</code>, and
|
||||
@@ -182,6 +188,19 @@
|
||||
<throws><simpara>Does not throw.</simpara></throws>
|
||||
</function>
|
||||
</free-function-group>
|
||||
|
||||
<free-function-group name="access">
|
||||
<function name="unwrap_ref">
|
||||
<type>unwrap_reference<T>::type&</type>
|
||||
<parameter name="t">
|
||||
<paramtype>T&</paramtype>
|
||||
</parameter>
|
||||
|
||||
<returns><simpara><computeroutput><classname>unwrap_reference</classname><T>::type&(t)</computeroutput></simpara></returns>
|
||||
|
||||
<throws><simpara>Does not throw.</simpara></throws>
|
||||
</function>
|
||||
</free-function-group>
|
||||
</class>
|
||||
|
||||
<class name="is_reference_wrapper">
|
||||
@@ -236,7 +255,8 @@
|
||||
Peter Dimov because they are generally useful. Douglas Gregor and
|
||||
Dave Abrahams contributed
|
||||
<classname>is_reference_wrapper</classname> and
|
||||
<classname>unwrap_reference</classname>.</para>
|
||||
<classname>unwrap_reference</classname>. Frank Mori Hess and Ronald
|
||||
Garcia contributed <functionname>boost::unwrap_ref</functionname></para>
|
||||
</section>
|
||||
|
||||
</library>
|
||||
</library>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,18 +19,44 @@
|
||||
// See http://www.boost.org/libs/bind/bind.html for documentation.
|
||||
//
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/is_placeholder.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template<int I> class arg
|
||||
template< int I > struct 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;
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
#endif // #ifndef BOOST_BIND_ARG_HPP_INCLUDED
|
||||
|
||||
1751
include/boost/bind/bind.hpp
Normal file
1751
include/boost/bind/bind.hpp
Normal file
File diff suppressed because it is too large
Load Diff
228
include/boost/bind/bind_mf2_cc.hpp
Normal file
228
include/boost/bind/bind_mf2_cc.hpp
Normal file
@@ -0,0 +1,228 @@
|
||||
//
|
||||
// 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,6 +38,23 @@
|
||||
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)
|
||||
{
|
||||
list2<A1 &, A2 &> a(a1, a2);
|
||||
@@ -50,6 +67,49 @@
|
||||
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)
|
||||
{
|
||||
list3<A1 &, A2 &, A3 &> a(a1, a2, a3);
|
||||
@@ -62,6 +122,23 @@
|
||||
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)
|
||||
{
|
||||
list4<A1 &, A2 &, A3 &, A4 &> a(a1, a2, a3, a4);
|
||||
@@ -74,6 +151,23 @@
|
||||
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)
|
||||
{
|
||||
list5<A1 &, A2 &, A3 &, A4 &, A5 &> a(a1, a2, a3, a4, a5);
|
||||
@@ -86,6 +180,23 @@
|
||||
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)
|
||||
{
|
||||
list6<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &> a(a1, a2, a3, a4, a5, a6);
|
||||
@@ -98,6 +209,23 @@
|
||||
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)
|
||||
{
|
||||
list7<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &> a(a1, a2, a3, a4, a5, a6, a7);
|
||||
@@ -110,6 +238,23 @@
|
||||
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)
|
||||
{
|
||||
list8<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &, A8 &> a(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
@@ -122,6 +267,23 @@
|
||||
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)
|
||||
{
|
||||
list9<A1 &, A2 &, A3 &, A4 &, A5 &, A6 &, A7 &, A8 &, A9 &> a(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||
@@ -134,6 +296,23 @@
|
||||
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)
|
||||
{
|
||||
BOOST_BIND_RETURN l_(type<result_type>(), f_, a, 0);
|
||||
@@ -146,6 +325,11 @@
|
||||
|
||||
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);
|
||||
l_.accept(v);
|
||||
}
|
||||
|
||||
389
include/boost/bind/mem_fn.hpp
Normal file
389
include/boost/bind/mem_fn.hpp
Normal file
@@ -0,0 +1,389 @@
|
||||
#ifndef BOOST_BIND_MEM_FN_HPP_INCLUDED
|
||||
#define BOOST_BIND_MEM_FN_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//
|
||||
// mem_fn.hpp - a generalization of std::mem_fun[_ref]
|
||||
//
|
||||
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
// Copyright (c) 2001 David Abrahams
|
||||
// Copyright (c) 2003-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)
|
||||
//
|
||||
// See http://www.boost.org/libs/bind/mem_fn.html for documentation.
|
||||
//
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/get_pointer.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
#if defined(BOOST_NO_VOID_RETURNS)
|
||||
|
||||
#define BOOST_MEM_FN_CLASS_F , class F
|
||||
#define BOOST_MEM_FN_TYPEDEF(X)
|
||||
|
||||
namespace _mfi // mem_fun_impl
|
||||
{
|
||||
|
||||
template<class V> struct mf
|
||||
{
|
||||
|
||||
#define BOOST_MEM_FN_RETURN return
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) inner_##X
|
||||
#define BOOST_MEM_FN_CC
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_CDECL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) inner_##X##_cdecl
|
||||
#define BOOST_MEM_FN_CC __cdecl
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_STDCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall
|
||||
#define BOOST_MEM_FN_CC __stdcall
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_FASTCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) inner_##X##_fastcall
|
||||
#define BOOST_MEM_FN_CC __fastcall
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#endif
|
||||
|
||||
#undef BOOST_MEM_FN_RETURN
|
||||
|
||||
}; // struct mf<V>
|
||||
|
||||
template<> struct mf<void>
|
||||
{
|
||||
|
||||
#define BOOST_MEM_FN_RETURN
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) inner_##X
|
||||
#define BOOST_MEM_FN_CC
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_CDECL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) inner_##X##_cdecl
|
||||
#define BOOST_MEM_FN_CC __cdecl
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_STDCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall
|
||||
#define BOOST_MEM_FN_CC __stdcall
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_FASTCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) inner_##X##_fastcall
|
||||
#define BOOST_MEM_FN_CC __fastcall
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#endif
|
||||
|
||||
#undef BOOST_MEM_FN_RETURN
|
||||
|
||||
}; // struct mf<void>
|
||||
|
||||
#undef BOOST_MEM_FN_CLASS_F
|
||||
#undef BOOST_MEM_FN_TYPEDEF_F
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X
|
||||
#define BOOST_MEM_FN_NAME2(X) inner_##X
|
||||
#define BOOST_MEM_FN_CC
|
||||
|
||||
#include <boost/bind/mem_fn_vw.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
#undef BOOST_MEM_FN_NAME2
|
||||
#undef BOOST_MEM_FN_CC
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_CDECL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X##_cdecl
|
||||
#define BOOST_MEM_FN_NAME2(X) inner_##X##_cdecl
|
||||
#define BOOST_MEM_FN_CC __cdecl
|
||||
|
||||
#include <boost/bind/mem_fn_vw.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
#undef BOOST_MEM_FN_NAME2
|
||||
#undef BOOST_MEM_FN_CC
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_STDCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X##_stdcall
|
||||
#define BOOST_MEM_FN_NAME2(X) inner_##X##_stdcall
|
||||
#define BOOST_MEM_FN_CC __stdcall
|
||||
|
||||
#include <boost/bind/mem_fn_vw.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
#undef BOOST_MEM_FN_NAME2
|
||||
#undef BOOST_MEM_FN_CC
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_FASTCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X##_fastcall
|
||||
#define BOOST_MEM_FN_NAME2(X) inner_##X##_fastcall
|
||||
#define BOOST_MEM_FN_CC __fastcall
|
||||
|
||||
#include <boost/bind/mem_fn_vw.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
#undef BOOST_MEM_FN_NAME2
|
||||
#undef BOOST_MEM_FN_CC
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace _mfi
|
||||
|
||||
#else // #ifdef BOOST_NO_VOID_RETURNS
|
||||
|
||||
#define BOOST_MEM_FN_CLASS_F
|
||||
#define BOOST_MEM_FN_TYPEDEF(X) typedef X;
|
||||
|
||||
namespace _mfi
|
||||
{
|
||||
|
||||
#define BOOST_MEM_FN_RETURN return
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X
|
||||
#define BOOST_MEM_FN_CC
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_CDECL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X##_cdecl
|
||||
#define BOOST_MEM_FN_CC __cdecl
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_STDCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X##_stdcall
|
||||
#define BOOST_MEM_FN_CC __stdcall
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_FASTCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X##_fastcall
|
||||
#define BOOST_MEM_FN_CC __fastcall
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#endif
|
||||
|
||||
#undef BOOST_MEM_FN_RETURN
|
||||
|
||||
} // namespace _mfi
|
||||
|
||||
#undef BOOST_MEM_FN_CLASS_F
|
||||
#undef BOOST_MEM_FN_TYPEDEF
|
||||
|
||||
#endif // #ifdef BOOST_NO_VOID_RETURNS
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X
|
||||
#define BOOST_MEM_FN_CC
|
||||
|
||||
#include <boost/bind/mem_fn_cc.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
#undef BOOST_MEM_FN_CC
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_CDECL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X##_cdecl
|
||||
#define BOOST_MEM_FN_CC __cdecl
|
||||
|
||||
#include <boost/bind/mem_fn_cc.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
#undef BOOST_MEM_FN_CC
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_STDCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X##_stdcall
|
||||
#define BOOST_MEM_FN_CC __stdcall
|
||||
|
||||
#include <boost/bind/mem_fn_cc.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
#undef BOOST_MEM_FN_CC
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_FASTCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X##_fastcall
|
||||
#define BOOST_MEM_FN_CC __fastcall
|
||||
|
||||
#include <boost/bind/mem_fn_cc.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
#undef BOOST_MEM_FN_CC
|
||||
|
||||
#endif
|
||||
|
||||
// data member support
|
||||
|
||||
namespace _mfi
|
||||
{
|
||||
|
||||
template<class R, class T> class dm
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R const & result_type;
|
||||
typedef T const * argument_type;
|
||||
|
||||
private:
|
||||
|
||||
typedef R (T::*F);
|
||||
F f_;
|
||||
|
||||
template<class U> R const & call(U & u, T const *) const
|
||||
{
|
||||
return (u.*f_);
|
||||
}
|
||||
|
||||
template<class U> R const & call(U & u, void const *) const
|
||||
{
|
||||
return (get_pointer(u)->*f_);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit dm(F f): f_(f) {}
|
||||
|
||||
R & operator()(T * p) const
|
||||
{
|
||||
return (p->*f_);
|
||||
}
|
||||
|
||||
R const & operator()(T const * p) const
|
||||
{
|
||||
return (p->*f_);
|
||||
}
|
||||
|
||||
template<class U> R const & operator()(U const & u) const
|
||||
{
|
||||
return call(u, &u);
|
||||
}
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) && !BOOST_WORKAROUND(__MWERKS__, < 0x3200)
|
||||
|
||||
R & operator()(T & t) const
|
||||
{
|
||||
return (t.*f_);
|
||||
}
|
||||
|
||||
R const & operator()(T const & t) const
|
||||
{
|
||||
return (t.*f_);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool operator==(dm const & rhs) const
|
||||
{
|
||||
return f_ == rhs.f_;
|
||||
}
|
||||
|
||||
bool operator!=(dm const & rhs) const
|
||||
{
|
||||
return f_ != rhs.f_;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace _mfi
|
||||
|
||||
template<class R, class T> _mfi::dm<R, T> mem_fn(R T::*f)
|
||||
{
|
||||
return _mfi::dm<R, T>(f);
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_BIND_MEM_FN_HPP_INCLUDED
|
||||
@@ -12,6 +12,10 @@
|
||||
// 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
|
||||
|
||||
template<class R, class T BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(mf0)
|
||||
@@ -47,9 +51,20 @@ public:
|
||||
|
||||
template<class U> R operator()(U & u) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u);
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p);
|
||||
}
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
|
||||
|
||||
template<class U> R operator()(U const & u) const
|
||||
{
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
R operator()(T & t) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)();
|
||||
@@ -96,7 +111,8 @@ public:
|
||||
|
||||
template<class U> R operator()(U const & u) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u);
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p);
|
||||
}
|
||||
|
||||
R operator()(T const & t) const
|
||||
@@ -151,9 +167,20 @@ public:
|
||||
|
||||
template<class U> R operator()(U & u, A1 a1) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1);
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, a1);
|
||||
}
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
|
||||
|
||||
template<class U> R operator()(U const & u, A1 a1) const
|
||||
{
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, a1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
R operator()(T & t, A1 a1) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)(a1);
|
||||
@@ -201,7 +228,8 @@ public:
|
||||
|
||||
template<class U> R operator()(U const & u, A1 a1) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1);
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, a1);
|
||||
}
|
||||
|
||||
R operator()(T const & t, A1 a1) const
|
||||
@@ -254,9 +282,20 @@ public:
|
||||
|
||||
template<class U> R operator()(U & u, A1 a1, A2 a2) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2);
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, a1, a2);
|
||||
}
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
|
||||
|
||||
template<class U> R operator()(U const & u, A1 a1, A2 a2) const
|
||||
{
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, a1, a2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
R operator()(T & t, A1 a1, A2 a2) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2);
|
||||
@@ -302,7 +341,8 @@ public:
|
||||
|
||||
template<class U> R operator()(U const & u, A1 a1, A2 a2) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2);
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, a1, a2);
|
||||
}
|
||||
|
||||
R operator()(T const & t, A1 a1, A2 a2) const
|
||||
@@ -355,9 +395,20 @@ public:
|
||||
|
||||
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3);
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, 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
|
||||
{
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
R operator()(T & t, A1 a1, A2 a2, A3 a3) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3);
|
||||
@@ -403,7 +454,8 @@ public:
|
||||
|
||||
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);
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3);
|
||||
}
|
||||
|
||||
R operator()(T const & t, A1 a1, A2 a2, A3 a3) const
|
||||
@@ -456,9 +508,20 @@ public:
|
||||
|
||||
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4);
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, 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
|
||||
{
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
R operator()(T & t, A1 a1, A2 a2, A3 a3, A4 a4) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4);
|
||||
@@ -504,7 +567,8 @@ public:
|
||||
|
||||
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);
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4);
|
||||
}
|
||||
|
||||
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4) const
|
||||
@@ -557,9 +621,20 @@ public:
|
||||
|
||||
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5);
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, 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
|
||||
{
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
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);
|
||||
@@ -605,7 +680,8 @@ public:
|
||||
|
||||
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);
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5);
|
||||
}
|
||||
|
||||
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
|
||||
@@ -658,9 +734,20 @@ public:
|
||||
|
||||
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6);
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, 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
|
||||
{
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
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);
|
||||
@@ -706,7 +793,8 @@ public:
|
||||
|
||||
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);
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6);
|
||||
}
|
||||
|
||||
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
|
||||
@@ -759,9 +847,20 @@ public:
|
||||
|
||||
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7);
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, 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
|
||||
{
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, 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
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6, a7);
|
||||
@@ -807,7 +906,8 @@ public:
|
||||
|
||||
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);
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7);
|
||||
}
|
||||
|
||||
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
|
||||
@@ -860,9 +960,20 @@ public:
|
||||
|
||||
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
|
||||
{
|
||||
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, 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
|
||||
{
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, 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
|
||||
{
|
||||
BOOST_MEM_FN_RETURN (t.*f_)(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
@@ -913,7 +1024,8 @@ public:
|
||||
|
||||
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);
|
||||
U const * p = 0;
|
||||
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
}
|
||||
|
||||
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
|
||||
@@ -932,3 +1044,4 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
#undef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
namespace
|
||||
{
|
||||
|
||||
#if defined(__BORLANDC__)
|
||||
#if defined(__BORLANDC__) || defined(__GNUC__) && (__GNUC__ < 4)
|
||||
|
||||
static inline boost::arg<1> _1() { return boost::arg<1>(); }
|
||||
static inline boost::arg<2> _2() { return boost::arg<2>(); }
|
||||
@@ -37,7 +37,8 @@ static inline boost::arg<7> _7() { return boost::arg<7>(); }
|
||||
static inline boost::arg<8> _8() { return boost::arg<8>(); }
|
||||
static inline boost::arg<9> _9() { return boost::arg<9>(); }
|
||||
|
||||
#elif defined(BOOST_MSVC) || (defined(__DECCXX_VER) && __DECCXX_VER <= 60590031) || defined(__MWERKS__)
|
||||
#elif defined(BOOST_MSVC) || (defined(__DECCXX_VER) && __DECCXX_VER <= 60590031) || defined(__MWERKS__) || \
|
||||
defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
|
||||
|
||||
static boost::arg<1> _1;
|
||||
static boost::arg<2> _2;
|
||||
|
||||
@@ -5,12 +5,16 @@
|
||||
// protect.hpp
|
||||
//
|
||||
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
|
||||
// Copyright (c) 2009 Steven Watanabe
|
||||
//
|
||||
// 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/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
@@ -47,6 +51,22 @@ public:
|
||||
return f_(a1);
|
||||
}
|
||||
|
||||
|
||||
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \
|
||||
&& !BOOST_WORKAROUND(__EDG_VERSION__, <= 238)
|
||||
|
||||
template<class A1> result_type operator()(const A1 & a1)
|
||||
{
|
||||
return f_(a1);
|
||||
}
|
||||
|
||||
template<class A1> result_type operator()(const A1 & a1) const
|
||||
{
|
||||
return f_(a1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template<class A1, class A2> result_type operator()(A1 & a1, A2 & a2)
|
||||
{
|
||||
return f_(a1, a2);
|
||||
@@ -57,6 +77,41 @@ public:
|
||||
return f_(a1, a2);
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
return f_(a1, a2);
|
||||
}
|
||||
|
||||
template<class A1, class A2> result_type operator()(A1 const & a1, A2 & a2) const
|
||||
{
|
||||
return f_(a1, a2);
|
||||
}
|
||||
|
||||
template<class A1, class A2> result_type operator()(A1 & a1, A2 const & a2)
|
||||
{
|
||||
return f_(a1, a2);
|
||||
}
|
||||
|
||||
template<class A1, class A2> result_type operator()(A1 & a1, A2 const & a2) const
|
||||
{
|
||||
return f_(a1, a2);
|
||||
}
|
||||
|
||||
template<class A1, class A2> result_type operator()(A1 const & a1, A2 const & a2)
|
||||
{
|
||||
return f_(a1, a2);
|
||||
}
|
||||
|
||||
template<class A1, class A2> result_type operator()(A1 const & a1, A2 const & a2) const
|
||||
{
|
||||
return f_(a1, a2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template<class A1, class A2, class A3> result_type operator()(A1 & a1, A2 & a2, A3 & a3)
|
||||
{
|
||||
return f_(a1, a2, a3);
|
||||
@@ -66,6 +121,21 @@ public:
|
||||
{
|
||||
return f_(a1, a2, a3);
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
return f_(a1, a2, a3);
|
||||
}
|
||||
|
||||
template<class A1, class A2, class A3> result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3) const
|
||||
{
|
||||
return f_(a1, a2, a3);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template<class A1, class A2, class A3, class A4> result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4)
|
||||
{
|
||||
@@ -76,6 +146,21 @@ public:
|
||||
{
|
||||
return f_(a1, a2, a3, a4);
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
return f_(a1, a2, a3, a4);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
return f_(a1, a2, a3, a4);
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
@@ -86,6 +171,21 @@ public:
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5);
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5);
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
@@ -96,6 +196,21 @@ public:
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6);
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6);
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
@@ -106,6 +221,21 @@ public:
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6, a7);
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6, a7);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6, a7);
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
@@ -116,6 +246,21 @@ public:
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
@@ -126,6 +271,21 @@ public:
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
return f_(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
|
||||
475
include/boost/bind/storage.hpp
Normal file
475
include/boost/bind/storage.hpp
Normal file
@@ -0,0 +1,475 @@
|
||||
#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
|
||||
31
include/boost/is_placeholder.hpp
Normal file
31
include/boost/is_placeholder.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#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
|
||||
@@ -10,322 +10,15 @@
|
||||
//
|
||||
// mem_fn.hpp - a generalization of std::mem_fun[_ref]
|
||||
//
|
||||
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
// Copyright (c) 2001 David Abrahams
|
||||
// Copyright (c) 2009 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)
|
||||
// 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/mem_fn.html for documentation.
|
||||
//
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/get_pointer.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
#if defined(BOOST_NO_VOID_RETURNS)
|
||||
|
||||
#define BOOST_MEM_FN_CLASS_F , class F
|
||||
#define BOOST_MEM_FN_TYPEDEF(X)
|
||||
|
||||
namespace _mfi // mem_fun_impl
|
||||
{
|
||||
|
||||
template<class V> struct mf
|
||||
{
|
||||
|
||||
#define BOOST_MEM_FN_RETURN return
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) inner_##X
|
||||
#define BOOST_MEM_FN_CC
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_STDCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall
|
||||
#define BOOST_MEM_FN_CC __stdcall
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_FASTCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) inner_##X##_fastcall
|
||||
#define BOOST_MEM_FN_CC __fastcall
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#endif
|
||||
|
||||
#undef BOOST_MEM_FN_RETURN
|
||||
|
||||
}; // struct mf<V>
|
||||
|
||||
template<> struct mf<void>
|
||||
{
|
||||
|
||||
#define BOOST_MEM_FN_RETURN
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) inner_##X
|
||||
#define BOOST_MEM_FN_CC
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_STDCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall
|
||||
#define BOOST_MEM_FN_CC __stdcall
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_FASTCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) inner_##X##_fastcall
|
||||
#define BOOST_MEM_FN_CC __fastcall
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#endif
|
||||
|
||||
#undef BOOST_MEM_FN_RETURN
|
||||
|
||||
}; // struct mf<void>
|
||||
|
||||
#undef BOOST_MEM_FN_CLASS_F
|
||||
#undef BOOST_MEM_FN_TYPEDEF_F
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X
|
||||
#define BOOST_MEM_FN_NAME2(X) inner_##X
|
||||
#define BOOST_MEM_FN_CC
|
||||
|
||||
#include <boost/bind/mem_fn_vw.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
#undef BOOST_MEM_FN_NAME2
|
||||
#undef BOOST_MEM_FN_CC
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_STDCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X##_stdcall
|
||||
#define BOOST_MEM_FN_NAME2(X) inner_##X##_stdcall
|
||||
#define BOOST_MEM_FN_CC __stdcall
|
||||
|
||||
#include <boost/bind/mem_fn_vw.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
#undef BOOST_MEM_FN_NAME2
|
||||
#undef BOOST_MEM_FN_CC
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_FASTCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X##_fastcall
|
||||
#define BOOST_MEM_FN_NAME2(X) inner_##X##_fastcall
|
||||
#define BOOST_MEM_FN_CC __fastcall
|
||||
|
||||
#include <boost/bind/mem_fn_vw.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
#undef BOOST_MEM_FN_NAME2
|
||||
#undef BOOST_MEM_FN_CC
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace _mfi
|
||||
|
||||
#else // #ifdef BOOST_NO_VOID_RETURNS
|
||||
|
||||
#define BOOST_MEM_FN_CLASS_F
|
||||
#define BOOST_MEM_FN_TYPEDEF(X) typedef X;
|
||||
|
||||
namespace _mfi
|
||||
{
|
||||
|
||||
#define BOOST_MEM_FN_RETURN return
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X
|
||||
#define BOOST_MEM_FN_CC
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_STDCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X##_stdcall
|
||||
#define BOOST_MEM_FN_CC __stdcall
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_FASTCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X##_fastcall
|
||||
#define BOOST_MEM_FN_CC __fastcall
|
||||
|
||||
#include <boost/bind/mem_fn_template.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_CC
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
|
||||
#endif
|
||||
|
||||
#undef BOOST_MEM_FN_RETURN
|
||||
|
||||
} // namespace _mfi
|
||||
|
||||
#undef BOOST_MEM_FN_CLASS_F
|
||||
#undef BOOST_MEM_FN_TYPEDEF
|
||||
|
||||
#endif // #ifdef BOOST_NO_VOID_RETURNS
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X
|
||||
#define BOOST_MEM_FN_CC
|
||||
|
||||
#include <boost/bind/mem_fn_cc.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
#undef BOOST_MEM_FN_CC
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_STDCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X##_stdcall
|
||||
#define BOOST_MEM_FN_CC __stdcall
|
||||
|
||||
#include <boost/bind/mem_fn_cc.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
#undef BOOST_MEM_FN_CC
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MEM_FN_ENABLE_FASTCALL
|
||||
|
||||
#define BOOST_MEM_FN_NAME(X) X##_fastcall
|
||||
#define BOOST_MEM_FN_CC __fastcall
|
||||
|
||||
#include <boost/bind/mem_fn_cc.hpp>
|
||||
|
||||
#undef BOOST_MEM_FN_NAME
|
||||
#undef BOOST_MEM_FN_CC
|
||||
|
||||
#endif
|
||||
|
||||
// data member support
|
||||
|
||||
namespace _mfi
|
||||
{
|
||||
|
||||
template<class R, class T> class dm
|
||||
{
|
||||
public:
|
||||
|
||||
typedef R const & result_type;
|
||||
typedef T const * argument_type;
|
||||
|
||||
private:
|
||||
|
||||
typedef R (T::*F);
|
||||
F f_;
|
||||
|
||||
template<class U> R const & call(U & u, T const *) const
|
||||
{
|
||||
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
|
||||
{
|
||||
return (get_pointer(u)->*f_);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit dm(F f): f_(f) {}
|
||||
|
||||
R & operator()(T * p) const
|
||||
{
|
||||
return (p->*f_);
|
||||
}
|
||||
|
||||
R const & operator()(T const * p) const
|
||||
{
|
||||
return (p->*f_);
|
||||
}
|
||||
|
||||
template<class U> R const & operator()(U & u) const
|
||||
{
|
||||
return call(u, &u);
|
||||
}
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) && !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
|
||||
|
||||
R & operator()(T & t) const
|
||||
{
|
||||
return (t.*f_);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
R const & operator()(T const & t) const
|
||||
{
|
||||
return (t.*f_);
|
||||
}
|
||||
|
||||
bool operator==(dm const & rhs) const
|
||||
{
|
||||
return f_ == rhs.f_;
|
||||
}
|
||||
|
||||
bool operator!=(dm const & rhs) const
|
||||
{
|
||||
return f_ != rhs.f_;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace _mfi
|
||||
|
||||
template<class R, class T> _mfi::dm<R, T> mem_fn(R T::*f)
|
||||
{
|
||||
return _mfi::dm<R, T>(f);
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
#include <boost/bind/mem_fn.hpp>
|
||||
|
||||
#endif // #ifndef BOOST_MEM_FN_HPP_INCLUDED
|
||||
|
||||
@@ -8,3 +8,9 @@ Automatic redirection failed, please go to
|
||||
<a href="mem_fn.html">mem_fn.html</a>.
|
||||
</body>
|
||||
</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
|
||||
-->
|
||||
|
||||
47
mem_fn.html
47
mem_fn.html
@@ -7,10 +7,9 @@
|
||||
<body bgcolor="white" style="MARGIN-LEFT: 5%; MARGIN-RIGHT: 5%">
|
||||
<table border="0" width="100%">
|
||||
<tr>
|
||||
<td width="277">
|
||||
<img src="../../boost.png" alt="boost.png (6897 bytes)" width="277" height="86">
|
||||
<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="middle">
|
||||
<td align="center">
|
||||
<h1>mem_fn.hpp</h1>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -37,8 +36,8 @@
|
||||
<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" and
|
||||
"__fastcall" Support</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>
|
||||
@@ -139,7 +138,7 @@ void k(std::vector<boost::shared_ptr<X> > const & v)
|
||||
<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 a const reference to the type of the member.
|
||||
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>
|
||||
@@ -171,7 +170,9 @@ void k(std::vector<boost::shared_ptr<X> > const & v)
|
||||
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.
|
||||
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>
|
||||
@@ -206,7 +207,7 @@ template<class R, class T, class A1, class A2> <i>unspecified-6</i> <a hre
|
||||
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 const &</tt>.
|
||||
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>
|
||||
@@ -333,8 +334,8 @@ template<class R, class T, class A1, class A2> <i>unspecified-6</i> <a hre
|
||||
<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>
|
||||
<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>
|
||||
@@ -346,7 +347,7 @@ template<class R, class T, class A1, class A2> <i>unspecified-6</i> <a hre
|
||||
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" and "__fastcall" Support</a></h3>
|
||||
<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
|
||||
@@ -355,7 +356,8 @@ template<class R, class T, class A1, class A2> <i>unspecified-6</i> <a hre
|
||||
</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>.
|
||||
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
|
||||
@@ -363,9 +365,15 @@ template<class R, class T, class A1, class A2> <i>unspecified-6</i> <a hre
|
||||
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, directly or
|
||||
indirectly, <B><boost/mem_fn.hpp></B>.
|
||||
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>
|
||||
@@ -387,13 +395,12 @@ template<class R, class T, class A1, class A2> <i>unspecified-6</i> <a hre
|
||||
Dave Abrahams modified <b>bind</b> and <b>mem_fn</b> to support void returns on
|
||||
deficient compilers.
|
||||
</p>
|
||||
<p><br>
|
||||
<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. Permission
|
||||
to copy, use, modify, sell and distribute this document is granted provided
|
||||
this copyright notice appears in all copies. This document is provided "as is"
|
||||
without express or implied warranty, and with no claim as to its suitability
|
||||
for any purpose.</small></p>
|
||||
<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>
|
||||
|
||||
6
ref.html
6
ref.html
@@ -7,3 +7,9 @@ Automatic redirection failed, please go to
|
||||
<a href="../../doc/html/ref.html">../../doc/html/ref.html</a>
|
||||
</body>
|
||||
</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
|
||||
-->
|
||||
|
||||
30
test/Jamfile
30
test/Jamfile
@@ -1,30 +0,0 @@
|
||||
# Boost.Bind Library test Jamfile
|
||||
#
|
||||
# Copyright (c) 2003, 2004 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_eq_test.cpp ]
|
||||
[ run bind_const_test.cpp ]
|
||||
[ run bind_cv_test.cpp ]
|
||||
[ run bind_stateful_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 ]
|
||||
;
|
||||
}
|
||||
@@ -1,24 +1,47 @@
|
||||
# Boost.Bind Library test Jamfile
|
||||
#
|
||||
# Copyright (c) 2003, 2004 Peter Dimov
|
||||
# Copyright (c) 2003-2006 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.
|
||||
# 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)
|
||||
|
||||
# bring in rules for testing
|
||||
import testing ;
|
||||
|
||||
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 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_void_test.cpp ]
|
||||
[ run mem_fn_derived_test.cpp ]
|
||||
[ run mem_fn_eq_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 ]
|
||||
[ run bind_eq2_test.cpp ]
|
||||
[ run mem_fn_ref_test.cpp ]
|
||||
[ run bind_ref_test.cpp ]
|
||||
[ run bind_eq3_test.cpp ]
|
||||
[ run protect_test.cpp ]
|
||||
[ run mem_fn_unary_addr_test.cpp ]
|
||||
;
|
||||
|
||||
|
||||
84
test/bind_and_or_test.cpp
Normal file
84
test/bind_and_or_test.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
#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();
|
||||
}
|
||||
164
test/bind_cdecl_mf_test.cpp
Normal file
164
test/bind_cdecl_mf_test.cpp
Normal file
@@ -0,0 +1,164 @@
|
||||
#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_cdecl_mf_test.cpp - test for bind.hpp + __cdecl (member functions)
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
|
||||
#define BOOST_MEM_FN_ENABLE_CDECL
|
||||
|
||||
#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 __cdecl f0() { f1(17); return 0; }
|
||||
int __cdecl g0() const { g1(17); return 0; }
|
||||
|
||||
int __cdecl f1(int a1) { hash = (hash * 17041 + a1) % 32768; return 0; }
|
||||
int __cdecl g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; }
|
||||
|
||||
int __cdecl f2(int a1, int a2) { f1(a1); f1(a2); return 0; }
|
||||
int __cdecl g2(int a1, int a2) const { g1(a1); g1(a2); return 0; }
|
||||
|
||||
int __cdecl f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; }
|
||||
int __cdecl g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; }
|
||||
|
||||
int __cdecl f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; }
|
||||
int __cdecl g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; }
|
||||
|
||||
int __cdecl f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; }
|
||||
int __cdecl g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; }
|
||||
|
||||
int __cdecl f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; }
|
||||
int __cdecl 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 __cdecl 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 __cdecl 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 __cdecl 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 __cdecl g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; }
|
||||
};
|
||||
|
||||
void member_function_test()
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
X x;
|
||||
|
||||
// 0
|
||||
|
||||
bind(&X::f0, &x)();
|
||||
bind(&X::f0, ref(x))();
|
||||
|
||||
bind(&X::g0, &x)();
|
||||
bind(&X::g0, x)();
|
||||
bind(&X::g0, ref(x))();
|
||||
|
||||
// 1
|
||||
|
||||
bind(&X::f1, &x, 1)();
|
||||
bind(&X::f1, ref(x), 1)();
|
||||
|
||||
bind(&X::g1, &x, 1)();
|
||||
bind(&X::g1, x, 1)();
|
||||
bind(&X::g1, ref(x), 1)();
|
||||
|
||||
// 2
|
||||
|
||||
bind(&X::f2, &x, 1, 2)();
|
||||
bind(&X::f2, ref(x), 1, 2)();
|
||||
|
||||
bind(&X::g2, &x, 1, 2)();
|
||||
bind(&X::g2, x, 1, 2)();
|
||||
bind(&X::g2, ref(x), 1, 2)();
|
||||
|
||||
// 3
|
||||
|
||||
bind(&X::f3, &x, 1, 2, 3)();
|
||||
bind(&X::f3, ref(x), 1, 2, 3)();
|
||||
|
||||
bind(&X::g3, &x, 1, 2, 3)();
|
||||
bind(&X::g3, x, 1, 2, 3)();
|
||||
bind(&X::g3, ref(x), 1, 2, 3)();
|
||||
|
||||
// 4
|
||||
|
||||
bind(&X::f4, &x, 1, 2, 3, 4)();
|
||||
bind(&X::f4, ref(x), 1, 2, 3, 4)();
|
||||
|
||||
bind(&X::g4, &x, 1, 2, 3, 4)();
|
||||
bind(&X::g4, x, 1, 2, 3, 4)();
|
||||
bind(&X::g4, ref(x), 1, 2, 3, 4)();
|
||||
|
||||
// 5
|
||||
|
||||
bind(&X::f5, &x, 1, 2, 3, 4, 5)();
|
||||
bind(&X::f5, ref(x), 1, 2, 3, 4, 5)();
|
||||
|
||||
bind(&X::g5, &x, 1, 2, 3, 4, 5)();
|
||||
bind(&X::g5, x, 1, 2, 3, 4, 5)();
|
||||
bind(&X::g5, ref(x), 1, 2, 3, 4, 5)();
|
||||
|
||||
// 6
|
||||
|
||||
bind(&X::f6, &x, 1, 2, 3, 4, 5, 6)();
|
||||
bind(&X::f6, ref(x), 1, 2, 3, 4, 5, 6)();
|
||||
|
||||
bind(&X::g6, &x, 1, 2, 3, 4, 5, 6)();
|
||||
bind(&X::g6, x, 1, 2, 3, 4, 5, 6)();
|
||||
bind(&X::g6, ref(x), 1, 2, 3, 4, 5, 6)();
|
||||
|
||||
// 7
|
||||
|
||||
bind(&X::f7, &x, 1, 2, 3, 4, 5, 6, 7)();
|
||||
bind(&X::f7, ref(x), 1, 2, 3, 4, 5, 6, 7)();
|
||||
|
||||
bind(&X::g7, &x, 1, 2, 3, 4, 5, 6, 7)();
|
||||
bind(&X::g7, x, 1, 2, 3, 4, 5, 6, 7)();
|
||||
bind(&X::g7, ref(x), 1, 2, 3, 4, 5, 6, 7)();
|
||||
|
||||
// 8
|
||||
|
||||
bind(&X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
bind(&X::f8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
|
||||
bind(&X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
bind(&X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
bind(&X::g8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
|
||||
BOOST_TEST( x.hash == 23558 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
member_function_test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
70
test/bind_dm2_test.cpp
Normal file
70
test/bind_dm2_test.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
#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_dm2_test.cpp - data members, advanced uses
|
||||
//
|
||||
// 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>
|
||||
#include <string>
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
int m;
|
||||
};
|
||||
|
||||
struct Y
|
||||
{
|
||||
char m[ 64 ];
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
X x = { 0 };
|
||||
X * px = &x;
|
||||
|
||||
boost::bind< int& >( &X::m, _1 )( px ) = 42;
|
||||
|
||||
BOOST_TEST( x.m == 42 );
|
||||
|
||||
boost::bind< int& >( &X::m, boost::ref(x) )() = 17041;
|
||||
|
||||
BOOST_TEST( x.m == 17041 );
|
||||
|
||||
X const * pcx = &x;
|
||||
|
||||
BOOST_TEST( boost::bind< long >( &X::m, _1 )( pcx ) == 17041L );
|
||||
BOOST_TEST( boost::bind< long >( &X::m, pcx )() == 17041L );
|
||||
|
||||
Y y = { "test" };
|
||||
std::string v( "test" );
|
||||
|
||||
BOOST_TEST( boost::bind< char const* >( &Y::m, &y )() == v );
|
||||
BOOST_TEST( boost::bind< std::string >( &Y::m, &y )() == v );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
46
test/bind_dm3_test.cpp
Normal file
46
test/bind_dm3_test.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#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();
|
||||
}
|
||||
73
test/bind_dm_test.cpp
Normal file
73
test/bind_dm_test.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
#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_dm_test.cpp - data members
|
||||
//
|
||||
// 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>
|
||||
|
||||
struct X
|
||||
{
|
||||
int m;
|
||||
};
|
||||
|
||||
X f( int v )
|
||||
{
|
||||
X r = { v };
|
||||
return r;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
X x = { 17041 };
|
||||
X * px = &x;
|
||||
|
||||
BOOST_TEST( boost::bind( &X::m, _1 )( x ) == 17041 );
|
||||
BOOST_TEST( boost::bind( &X::m, _1 )( px ) == 17041 );
|
||||
|
||||
BOOST_TEST( boost::bind( &X::m, x )() == 17041 );
|
||||
BOOST_TEST( boost::bind( &X::m, px )() == 17041 );
|
||||
BOOST_TEST( boost::bind( &X::m, boost::ref(x) )() == 17041 );
|
||||
|
||||
|
||||
X const cx = x;
|
||||
X const * pcx = &cx;
|
||||
|
||||
BOOST_TEST( boost::bind( &X::m, _1 )( cx ) == 17041 );
|
||||
BOOST_TEST( boost::bind( &X::m, _1 )( pcx ) == 17041 );
|
||||
|
||||
BOOST_TEST( boost::bind( &X::m, cx )() == 17041 );
|
||||
BOOST_TEST( boost::bind( &X::m, pcx )() == 17041 );
|
||||
BOOST_TEST( boost::bind( &X::m, boost::ref(cx) )() == 17041 );
|
||||
|
||||
int const v = 42;
|
||||
|
||||
BOOST_TEST( boost::bind( &X::m, boost::bind( f, _1 ) )( v ) == v );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
49
test/bind_eq2_test.cpp
Normal file
49
test/bind_eq2_test.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#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_eq2_test.cpp - boost::bind equality operator
|
||||
//
|
||||
// Copyright (c) 2004, 2005, 2009 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/function_equal.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
void f( int )
|
||||
{
|
||||
}
|
||||
|
||||
int g( int i )
|
||||
{
|
||||
return i + 5;
|
||||
}
|
||||
|
||||
template< class F > void test_self_equal( F f )
|
||||
{
|
||||
#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
|
||||
using boost::function_equal;
|
||||
#endif
|
||||
|
||||
BOOST_TEST( function_equal( f, f ) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_self_equal( boost::bind( f, _1 ) );
|
||||
test_self_equal( boost::bind( g, _1 ) );
|
||||
test_self_equal( boost::bind( f, boost::bind( g, _1 ) ) );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
45
test/bind_eq3_test.cpp
Normal file
45
test/bind_eq3_test.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#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_eq3_test.cpp - function_equal with bind and weak_ptr
|
||||
//
|
||||
// Copyright (c) 2004, 2005, 2009 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/function_equal.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
int f( boost::weak_ptr<void> wp )
|
||||
{
|
||||
return wp.use_count();
|
||||
}
|
||||
|
||||
template< class F > void test_self_equal( F f )
|
||||
{
|
||||
#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
|
||||
using boost::function_equal;
|
||||
#endif
|
||||
|
||||
BOOST_TEST( function_equal( f, f ) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_self_equal( boost::bind( f, _1 ) );
|
||||
test_self_equal( boost::bind( f, boost::weak_ptr<void>() ) );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
//
|
||||
// bind_eq_test.cpp - boost::bind equality operator
|
||||
//
|
||||
// Copyright (c) 2004 Peter Dimov
|
||||
// Copyright (c) 2004, 2005 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -20,6 +20,10 @@
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
|
||||
#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
|
||||
# include <boost/function_equal.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
|
||||
#pragma warning(push, 3)
|
||||
#endif
|
||||
@@ -142,14 +146,24 @@ void fv_9(X, X, X, X, X, X, X, X, X)
|
||||
|
||||
template<class F> void test_eq(F f1, F f2)
|
||||
{
|
||||
BOOST_TEST(f1 == f2);
|
||||
BOOST_TEST(!(f1 != f2));
|
||||
#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
|
||||
|
||||
using boost::function_equal;
|
||||
|
||||
#endif
|
||||
|
||||
BOOST_TEST( function_equal( f1, f2 ) );
|
||||
}
|
||||
|
||||
template<class F> void test_ne(F f1, F f2)
|
||||
{
|
||||
BOOST_TEST(f1 != f2);
|
||||
BOOST_TEST(!(f1 == f2));
|
||||
#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
|
||||
|
||||
using boost::function_equal;
|
||||
|
||||
#endif
|
||||
|
||||
BOOST_TEST( !function_equal( f1, f2 ) );
|
||||
}
|
||||
|
||||
// 0
|
||||
|
||||
171
test/bind_fn2_test.cpp
Normal file
171
test/bind_fn2_test.cpp
Normal file
@@ -0,0 +1,171 @@
|
||||
#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();
|
||||
}
|
||||
76
test/bind_fnobj2_test.cpp
Normal file
76
test/bind_fnobj2_test.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
#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();
|
||||
}
|
||||
77
test/bind_function_test.cpp
Normal file
77
test/bind_function_test.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
#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_function_test.cpp - function<>
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
|
||||
#pragma warning(push, 3)
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/function.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
int f( int x )
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
int g( int x )
|
||||
{
|
||||
return x + 1;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::function0<int> fn;
|
||||
|
||||
BOOST_TEST( !fn.contains( boost::bind( f, 1 ) ) );
|
||||
BOOST_TEST( !fn.contains( boost::bind( f, 2 ) ) );
|
||||
BOOST_TEST( !fn.contains( boost::bind( g, 1 ) ) );
|
||||
|
||||
fn = boost::bind( f, 1 );
|
||||
|
||||
BOOST_TEST( fn() == 1 );
|
||||
|
||||
BOOST_TEST( fn.contains( boost::bind( f, 1 ) ) );
|
||||
BOOST_TEST( !fn.contains( boost::bind( f, 2 ) ) );
|
||||
BOOST_TEST( !fn.contains( boost::bind( g, 1 ) ) );
|
||||
|
||||
fn = boost::bind( f, 2 );
|
||||
|
||||
BOOST_TEST( fn() == 2 );
|
||||
|
||||
BOOST_TEST( !fn.contains( boost::bind( f, 1 ) ) );
|
||||
BOOST_TEST( fn.contains( boost::bind( f, 2 ) ) );
|
||||
BOOST_TEST( !fn.contains( boost::bind( g, 1 ) ) );
|
||||
|
||||
fn = boost::bind( g, 1 );
|
||||
|
||||
BOOST_TEST( fn() == 2 );
|
||||
|
||||
BOOST_TEST( !fn.contains( boost::bind( f, 1 ) ) );
|
||||
BOOST_TEST( !fn.contains( boost::bind( f, 2 ) ) );
|
||||
BOOST_TEST( fn.contains( boost::bind( g, 1 ) ) );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
40
test/bind_lookup_problem_test.cpp
Normal file
40
test/bind_lookup_problem_test.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// bind_lookup_problem_test.cpp
|
||||
//
|
||||
// Copyright (C) Markus Schoepflin 2005.
|
||||
//
|
||||
// Use, modification, and distribution are subject to 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>
|
||||
|
||||
template<class T> void value();
|
||||
|
||||
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) { }
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::bind(f0);
|
||||
boost::bind(f1, 0);
|
||||
boost::bind(f2, 0, 0);
|
||||
boost::bind(f3, 0, 0, 0);
|
||||
boost::bind(f4, 0, 0, 0, 0);
|
||||
boost::bind(f5, 0, 0, 0, 0, 0);
|
||||
boost::bind(f6, 0, 0, 0, 0, 0, 0);
|
||||
boost::bind(f7, 0, 0, 0, 0, 0, 0, 0);
|
||||
boost::bind(f8, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
boost::bind(f9, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
162
test/bind_mf2_test.cpp
Normal file
162
test/bind_mf2_test.cpp
Normal file
@@ -0,0 +1,162 @@
|
||||
#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();
|
||||
}
|
||||
57
test/bind_not_test.cpp
Normal file
57
test/bind_not_test.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#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_not_test.cpp - operator!
|
||||
//
|
||||
// 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>
|
||||
|
||||
template<class F, class A1, class R> void test( F f, A1 a1, R r )
|
||||
{
|
||||
BOOST_TEST( f(a1) == r );
|
||||
}
|
||||
|
||||
bool f( bool v )
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
int g( int v )
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test( !boost::bind( f, true ), 0, !f( true ) );
|
||||
test( !boost::bind( g, _1 ), 5, !g( 5 ) );
|
||||
test( boost::bind( f, !boost::bind( f, true ) ), 0, f( !f( true ) ) );
|
||||
test( boost::bind( f, !boost::bind( f, _1 ) ), true, f( !f( true ) ) );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
83
test/bind_placeholder_test.cpp
Normal file
83
test/bind_placeholder_test.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
#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();
|
||||
}
|
||||
36
test/bind_ref_test.cpp
Normal file
36
test/bind_ref_test.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// bind_ref_test.cpp - reference_wrapper
|
||||
//
|
||||
// Copyright (c) 2009 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/ref.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
int f( int x )
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
int g( int x ) const
|
||||
{
|
||||
return -x;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
X x;
|
||||
|
||||
BOOST_TEST( boost::bind( &X::f, _1, 1 )( boost::ref( x ) ) == 1 );
|
||||
BOOST_TEST( boost::bind( &X::g, _1, 2 )( boost::cref( x ) ) == -2 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
97
test/bind_rel_test.cpp
Normal file
97
test/bind_rel_test.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
#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_rel_test.cpp - ==, !=, <, <=, >, >= operators
|
||||
//
|
||||
// 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>
|
||||
|
||||
int f( int x )
|
||||
{
|
||||
return x + x;
|
||||
}
|
||||
|
||||
int g( int x )
|
||||
{
|
||||
return 2 * x;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int x = 4;
|
||||
int y = x + x;
|
||||
|
||||
// bind op value
|
||||
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) == y )( x ) );
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) != y )( x ) ) );
|
||||
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) < y )( x ) ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) < y + 1 )( x ) );
|
||||
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) > y )( x ) ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) > y - 1 )( x ) );
|
||||
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) <= y - 1 )( x ) ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) <= y )( x ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) <= y + 1 )( x ) );
|
||||
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) >= y + 1 )( x ) ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) >= y )( x ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) >= y - 1 )( x ) );
|
||||
|
||||
// bind op ref
|
||||
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) == boost::ref( y ) )( x ) );
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) != boost::ref( y ) )( x ) ) );
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) < boost::ref( y ) )( x ) ) );
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) > boost::ref( y ) )( x ) ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) <= boost::ref( y ) )( x ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) >= boost::ref( y ) )( x ) );
|
||||
|
||||
// bind op placeholder
|
||||
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) == _2 )( x, y ) );
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) != _2 )( x, y ) ) );
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) < _2 )( x, y ) ) );
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) > _2 )( x, y ) ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) <= _2 )( x, y ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) >= _2 )( x, y ) );
|
||||
|
||||
// bind op bind
|
||||
|
||||
// important: bind( f, _1 ) and bind( g, _1 ) have the same type
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) == boost::bind( g, _1 ) )( x ) );
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) != boost::bind( g, _1 ) )( x ) ) );
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) < boost::bind( g, _1 ) )( x ) ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) <= boost::bind( g, _1 ) )( x ) );
|
||||
BOOST_TEST( !( ( boost::bind( f, _1 ) > boost::bind( g, _1 ) )( x ) ) );
|
||||
BOOST_TEST( ( boost::bind( f, _1 ) >= boost::bind( g, _1 ) )( x ) );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
64
test/bind_rv_sp_test.cpp
Normal file
64
test/bind_rv_sp_test.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
#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();
|
||||
}
|
||||
81
test/bind_rvalue_test.cpp
Normal file
81
test/bind_rvalue_test.cpp
Normal file
@@ -0,0 +1,81 @@
|
||||
#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();
|
||||
}
|
||||
@@ -390,7 +390,7 @@ void member_function_test()
|
||||
bind(&X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
bind(&X::g8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
|
||||
BOOST_TEST( bind(&X::hash, _1)(x) == 23558 );
|
||||
BOOST_TEST( x.hash == 23558 );
|
||||
}
|
||||
|
||||
void member_function_void_test()
|
||||
@@ -480,7 +480,7 @@ void member_function_void_test()
|
||||
bind(&V::g8, v, 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
bind(&V::g8, ref(v), 1, 2, 3, 4, 5, 6, 7, 8)();
|
||||
|
||||
BOOST_TEST( bind(&V::hash, _1)(v) == 23558 );
|
||||
BOOST_TEST( v.hash == 23558 );
|
||||
}
|
||||
|
||||
void nested_bind_test()
|
||||
|
||||
147
test/bind_unary_addr.cpp
Normal file
147
test/bind_unary_addr.cpp
Normal file
@@ -0,0 +1,147 @@
|
||||
#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;
|
||||
}
|
||||
68
test/bind_visit_test.cpp
Normal file
68
test/bind_visit_test.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
#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
|
||||
# pragma warning(disable: 4100) // unreferenced formal parameter (it is referenced!)
|
||||
#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();
|
||||
}
|
||||
186
test/mem_fn_cdecl_test.cpp
Normal file
186
test/mem_fn_cdecl_test.cpp
Normal file
@@ -0,0 +1,186 @@
|
||||
#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_cdecl_test.cpp - a test for mem_fn.hpp + __cdecl
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
|
||||
#define BOOST_MEM_FN_ENABLE_CDECL
|
||||
|
||||
#include <boost/mem_fn.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
|
||||
#pragma warning(push, 3)
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
|
||||
struct X
|
||||
{
|
||||
mutable unsigned int hash;
|
||||
|
||||
X(): hash(0) {}
|
||||
|
||||
int __cdecl f0() { f1(17); return 0; }
|
||||
int __cdecl g0() const { g1(17); return 0; }
|
||||
|
||||
int __cdecl f1(int a1) { hash = (hash * 17041 + a1) % 32768; return 0; }
|
||||
int __cdecl g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; }
|
||||
|
||||
int __cdecl f2(int a1, int a2) { f1(a1); f1(a2); return 0; }
|
||||
int __cdecl g2(int a1, int a2) const { g1(a1); g1(a2); return 0; }
|
||||
|
||||
int __cdecl f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; }
|
||||
int __cdecl g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; }
|
||||
|
||||
int __cdecl f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; }
|
||||
int __cdecl g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; }
|
||||
|
||||
int __cdecl f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; }
|
||||
int __cdecl g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; }
|
||||
|
||||
int __cdecl f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; }
|
||||
int __cdecl 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 __cdecl 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 __cdecl 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 __cdecl 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 __cdecl g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; }
|
||||
};
|
||||
|
||||
int detect_errors(bool x)
|
||||
{
|
||||
if(x)
|
||||
{
|
||||
std::cerr << "no errors detected.\n";
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "test failed.\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::mem_fn;
|
||||
|
||||
X x;
|
||||
|
||||
X const & rcx = x;
|
||||
X const * pcx = &x;
|
||||
|
||||
boost::shared_ptr<X> sp(new X);
|
||||
|
||||
mem_fn(&X::f0)(x);
|
||||
mem_fn(&X::f0)(&x);
|
||||
mem_fn(&X::f0)(sp);
|
||||
|
||||
mem_fn(&X::g0)(x);
|
||||
mem_fn(&X::g0)(rcx);
|
||||
mem_fn(&X::g0)(&x);
|
||||
mem_fn(&X::g0)(pcx);
|
||||
mem_fn(&X::g0)(sp);
|
||||
|
||||
mem_fn(&X::f1)(x, 1);
|
||||
mem_fn(&X::f1)(&x, 1);
|
||||
mem_fn(&X::f1)(sp, 1);
|
||||
|
||||
mem_fn(&X::g1)(x, 1);
|
||||
mem_fn(&X::g1)(rcx, 1);
|
||||
mem_fn(&X::g1)(&x, 1);
|
||||
mem_fn(&X::g1)(pcx, 1);
|
||||
mem_fn(&X::g1)(sp, 1);
|
||||
|
||||
mem_fn(&X::f2)(x, 1, 2);
|
||||
mem_fn(&X::f2)(&x, 1, 2);
|
||||
mem_fn(&X::f2)(sp, 1, 2);
|
||||
|
||||
mem_fn(&X::g2)(x, 1, 2);
|
||||
mem_fn(&X::g2)(rcx, 1, 2);
|
||||
mem_fn(&X::g2)(&x, 1, 2);
|
||||
mem_fn(&X::g2)(pcx, 1, 2);
|
||||
mem_fn(&X::g2)(sp, 1, 2);
|
||||
|
||||
mem_fn(&X::f3)(x, 1, 2, 3);
|
||||
mem_fn(&X::f3)(&x, 1, 2, 3);
|
||||
mem_fn(&X::f3)(sp, 1, 2, 3);
|
||||
|
||||
mem_fn(&X::g3)(x, 1, 2, 3);
|
||||
mem_fn(&X::g3)(rcx, 1, 2, 3);
|
||||
mem_fn(&X::g3)(&x, 1, 2, 3);
|
||||
mem_fn(&X::g3)(pcx, 1, 2, 3);
|
||||
mem_fn(&X::g3)(sp, 1, 2, 3);
|
||||
|
||||
mem_fn(&X::f4)(x, 1, 2, 3, 4);
|
||||
mem_fn(&X::f4)(&x, 1, 2, 3, 4);
|
||||
mem_fn(&X::f4)(sp, 1, 2, 3, 4);
|
||||
|
||||
mem_fn(&X::g4)(x, 1, 2, 3, 4);
|
||||
mem_fn(&X::g4)(rcx, 1, 2, 3, 4);
|
||||
mem_fn(&X::g4)(&x, 1, 2, 3, 4);
|
||||
mem_fn(&X::g4)(pcx, 1, 2, 3, 4);
|
||||
mem_fn(&X::g4)(sp, 1, 2, 3, 4);
|
||||
|
||||
mem_fn(&X::f5)(x, 1, 2, 3, 4, 5);
|
||||
mem_fn(&X::f5)(&x, 1, 2, 3, 4, 5);
|
||||
mem_fn(&X::f5)(sp, 1, 2, 3, 4, 5);
|
||||
|
||||
mem_fn(&X::g5)(x, 1, 2, 3, 4, 5);
|
||||
mem_fn(&X::g5)(rcx, 1, 2, 3, 4, 5);
|
||||
mem_fn(&X::g5)(&x, 1, 2, 3, 4, 5);
|
||||
mem_fn(&X::g5)(pcx, 1, 2, 3, 4, 5);
|
||||
mem_fn(&X::g5)(sp, 1, 2, 3, 4, 5);
|
||||
|
||||
mem_fn(&X::f6)(x, 1, 2, 3, 4, 5, 6);
|
||||
mem_fn(&X::f6)(&x, 1, 2, 3, 4, 5, 6);
|
||||
mem_fn(&X::f6)(sp, 1, 2, 3, 4, 5, 6);
|
||||
|
||||
mem_fn(&X::g6)(x, 1, 2, 3, 4, 5, 6);
|
||||
mem_fn(&X::g6)(rcx, 1, 2, 3, 4, 5, 6);
|
||||
mem_fn(&X::g6)(&x, 1, 2, 3, 4, 5, 6);
|
||||
mem_fn(&X::g6)(pcx, 1, 2, 3, 4, 5, 6);
|
||||
mem_fn(&X::g6)(sp, 1, 2, 3, 4, 5, 6);
|
||||
|
||||
mem_fn(&X::f7)(x, 1, 2, 3, 4, 5, 6, 7);
|
||||
mem_fn(&X::f7)(&x, 1, 2, 3, 4, 5, 6, 7);
|
||||
mem_fn(&X::f7)(sp, 1, 2, 3, 4, 5, 6, 7);
|
||||
|
||||
mem_fn(&X::g7)(x, 1, 2, 3, 4, 5, 6, 7);
|
||||
mem_fn(&X::g7)(rcx, 1, 2, 3, 4, 5, 6, 7);
|
||||
mem_fn(&X::g7)(&x, 1, 2, 3, 4, 5, 6, 7);
|
||||
mem_fn(&X::g7)(pcx, 1, 2, 3, 4, 5, 6, 7);
|
||||
mem_fn(&X::g7)(sp, 1, 2, 3, 4, 5, 6, 7);
|
||||
|
||||
mem_fn(&X::f8)(x, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
mem_fn(&X::f8)(&x, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
mem_fn(&X::f8)(sp, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
|
||||
mem_fn(&X::g8)(x, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
mem_fn(&X::g8)(rcx, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
mem_fn(&X::g8)(&x, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
mem_fn(&X::g8)(pcx, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
mem_fn(&X::g8)(sp, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
|
||||
return detect_errors(x.hash == 17610 && sp->hash == 2155);
|
||||
}
|
||||
67
test/mem_fn_dm_test.cpp
Normal file
67
test/mem_fn_dm_test.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
#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_dm_test.cpp - data members
|
||||
//
|
||||
// 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>
|
||||
|
||||
#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
|
||||
{
|
||||
int m;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
X x = { 0 };
|
||||
|
||||
boost::mem_fn( &X::m )( x ) = 401;
|
||||
|
||||
BOOST_TEST( x.m == 401 );
|
||||
BOOST_TEST( boost::mem_fn( &X::m )( x ) == 401 );
|
||||
|
||||
boost::mem_fn( &X::m )( &x ) = 502;
|
||||
|
||||
BOOST_TEST( x.m == 502 );
|
||||
BOOST_TEST( boost::mem_fn( &X::m )( &x ) == 502 );
|
||||
|
||||
X * px = &x;
|
||||
|
||||
boost::mem_fn( &X::m )( px ) = 603;
|
||||
|
||||
BOOST_TEST( x.m == 603 );
|
||||
BOOST_TEST( boost::mem_fn( &X::m )( px ) == 603 );
|
||||
|
||||
X const & cx = x;
|
||||
X const * pcx = &x;
|
||||
|
||||
BOOST_TEST( boost::mem_fn( &X::m )( cx ) == 603 );
|
||||
BOOST_TEST( boost::mem_fn( &X::m )( pcx ) == 603 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
36
test/mem_fn_ref_test.cpp
Normal file
36
test/mem_fn_ref_test.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// mem_fn_ref_test.cpp - reference_wrapper
|
||||
//
|
||||
// Copyright (c) 2009 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/ref.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
int f()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int g() const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
X x;
|
||||
|
||||
BOOST_TEST( boost::mem_fn( &X::f )( boost::ref( x ) ) == 1 );
|
||||
BOOST_TEST( boost::mem_fn( &X::g )( boost::cref( x ) ) == 2 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
117
test/mem_fn_rv_test.cpp
Normal file
117
test/mem_fn_rv_test.cpp
Normal file
@@ -0,0 +1,117 @@
|
||||
#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 );
|
||||
}
|
||||
151
test/mem_fn_unary_addr_test.cpp
Normal file
151
test/mem_fn_unary_addr_test.cpp
Normal file
@@ -0,0 +1,151 @@
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.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_unary_addr_test.cpp - poisoned operator& test
|
||||
//
|
||||
// Copyright (c) 2009 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>
|
||||
|
||||
#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; }
|
||||
};
|
||||
|
||||
template<class T> class Y
|
||||
{
|
||||
private:
|
||||
|
||||
T * pt_;
|
||||
|
||||
void operator& ();
|
||||
void operator& () const;
|
||||
|
||||
public:
|
||||
|
||||
explicit Y( T * pt ): pt_( pt )
|
||||
{
|
||||
}
|
||||
|
||||
T * get() const
|
||||
{
|
||||
return pt_;
|
||||
}
|
||||
};
|
||||
|
||||
#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x620 ) )
|
||||
namespace boost
|
||||
{
|
||||
#endif
|
||||
|
||||
template<class T> T * get_pointer( Y< T > const & y )
|
||||
{
|
||||
return y.get();
|
||||
}
|
||||
|
||||
#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x620 ) )
|
||||
} // namespace boost
|
||||
#endif
|
||||
|
||||
int detect_errors(bool x)
|
||||
{
|
||||
if( x )
|
||||
{
|
||||
std::cerr << "no errors detected.\n";
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "test failed.\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::mem_fn;
|
||||
|
||||
X x;
|
||||
|
||||
Y<X> px( &x );
|
||||
Y<X const> pcx( &x );
|
||||
|
||||
mem_fn(&X::f0)( px );
|
||||
mem_fn(&X::g0)( pcx );
|
||||
|
||||
mem_fn(&X::f1)( px, 1 );
|
||||
mem_fn(&X::g1)( pcx, 1 );
|
||||
|
||||
mem_fn(&X::f2)( px, 1, 2 );
|
||||
mem_fn(&X::g2)( pcx, 1, 2 );
|
||||
|
||||
mem_fn(&X::f3)( px, 1, 2, 3 );
|
||||
mem_fn(&X::g3)( pcx, 1, 2, 3 );
|
||||
|
||||
mem_fn(&X::f4)( px, 1, 2, 3, 4 );
|
||||
mem_fn(&X::g4)( pcx, 1, 2, 3, 4 );
|
||||
|
||||
mem_fn(&X::f5)( px, 1, 2, 3, 4, 5 );
|
||||
mem_fn(&X::g5)( pcx, 1, 2, 3, 4, 5 );
|
||||
|
||||
mem_fn(&X::f6)( px, 1, 2, 3, 4, 5, 6 );
|
||||
mem_fn(&X::g6)( pcx, 1, 2, 3, 4, 5, 6 );
|
||||
|
||||
mem_fn(&X::f7)( px, 1, 2, 3, 4, 5, 6, 7 );
|
||||
mem_fn(&X::g7)( pcx, 1, 2, 3, 4, 5, 6, 7 );
|
||||
|
||||
mem_fn(&X::f8)( px, 1, 2, 3, 4, 5, 6, 7, 8 );
|
||||
mem_fn(&X::g8)( pcx, 1, 2, 3, 4, 5, 6, 7, 8 );
|
||||
|
||||
return detect_errors( hash == 2155 );
|
||||
}
|
||||
281
test/protect_test.cpp
Normal file
281
test/protect_test.cpp
Normal file
@@ -0,0 +1,281 @@
|
||||
// protect_test.cpp
|
||||
//
|
||||
// Copyright (c) 2009 Steven Watanabe
|
||||
//
|
||||
// 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/protect.hpp>
|
||||
#include <boost/bind/bind.hpp>
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
int f(int x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
int& g(int& x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
const T& constify(const T& arg)
|
||||
{
|
||||
return arg;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int i[9] = {0,1,2,3,4,5,6,7,8};
|
||||
|
||||
// non-const
|
||||
|
||||
// test nullary
|
||||
BOOST_TEST(boost::protect(boost::bind(f, 1))() == 1);
|
||||
|
||||
// test lvalues
|
||||
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _1))(i[0]) == &i[0]);
|
||||
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _1))(i[0], i[1]) == &i[0]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _2))(i[0], i[1]) == &i[1]);
|
||||
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _1))(i[0], i[1], i[2]) == &i[0]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _2))(i[0], i[1], i[2]) == &i[1]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _3))(i[0], i[1], i[2]) == &i[2]);
|
||||
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _1))(i[0], i[1], i[2], i[3]) == &i[0]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _2))(i[0], i[1], i[2], i[3]) == &i[1]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _3))(i[0], i[1], i[2], i[3]) == &i[2]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _4))(i[0], i[1], i[2], i[3]) == &i[3]);
|
||||
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _1))(i[0], i[1], i[2], i[3], i[4]) == &i[0]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _2))(i[0], i[1], i[2], i[3], i[4]) == &i[1]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _3))(i[0], i[1], i[2], i[3], i[4]) == &i[2]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _4))(i[0], i[1], i[2], i[3], i[4]) == &i[3]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _5))(i[0], i[1], i[2], i[3], i[4]) == &i[4]);
|
||||
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _1))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[0]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _2))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[1]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _3))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[2]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _4))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[3]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _5))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[4]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _6))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[5]);
|
||||
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _1))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[0]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _2))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[1]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _3))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[2]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _4))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[3]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _5))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[4]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _6))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[5]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _7))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[6]);
|
||||
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _1))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[0]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _2))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[1]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _3))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[2]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _4))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[3]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _5))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[4]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _6))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[5]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _7))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[6]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _8))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[7]);
|
||||
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _1))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[0]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _2))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[1]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _3))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[2]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _4))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[3]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _5))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[4]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _6))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[5]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _7))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[6]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _8))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[7]);
|
||||
BOOST_TEST(&boost::protect(boost::bind(g, _9))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[8]);
|
||||
|
||||
// test rvalues
|
||||
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _1))(0) == 0);
|
||||
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _1))(0, 1) == 0);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _2))(0, 1) == 1);
|
||||
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _1))(0, 1, 2) == 0);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _2))(0, 1, 2) == 1);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _3))(0, 1, 2) == 2);
|
||||
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _1))(0, 1, 2, 3) == 0);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _2))(0, 1, 2, 3) == 1);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _3))(0, 1, 2, 3) == 2);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _4))(0, 1, 2, 3) == 3);
|
||||
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _1))(0, 1, 2, 3, 4) == 0);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _2))(0, 1, 2, 3, 4) == 1);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _3))(0, 1, 2, 3, 4) == 2);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _4))(0, 1, 2, 3, 4) == 3);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _5))(0, 1, 2, 3, 4) == 4);
|
||||
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _1))(0, 1, 2, 3, 4, 5) == 0);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _2))(0, 1, 2, 3, 4, 5) == 1);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _3))(0, 1, 2, 3, 4, 5) == 2);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _4))(0, 1, 2, 3, 4, 5) == 3);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _5))(0, 1, 2, 3, 4, 5) == 4);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _6))(0, 1, 2, 3, 4, 5) == 5);
|
||||
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _1))(0, 1, 2, 3, 4, 5, 6) == 0);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _2))(0, 1, 2, 3, 4, 5, 6) == 1);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _3))(0, 1, 2, 3, 4, 5, 6) == 2);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _4))(0, 1, 2, 3, 4, 5, 6) == 3);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _5))(0, 1, 2, 3, 4, 5, 6) == 4);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _6))(0, 1, 2, 3, 4, 5, 6) == 5);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _7))(0, 1, 2, 3, 4, 5, 6) == 6);
|
||||
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _1))(0, 1, 2, 3, 4, 5, 6, 7) == 0);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _2))(0, 1, 2, 3, 4, 5, 6, 7) == 1);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _3))(0, 1, 2, 3, 4, 5, 6, 7) == 2);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _4))(0, 1, 2, 3, 4, 5, 6, 7) == 3);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _5))(0, 1, 2, 3, 4, 5, 6, 7) == 4);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _6))(0, 1, 2, 3, 4, 5, 6, 7) == 5);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _7))(0, 1, 2, 3, 4, 5, 6, 7) == 6);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _8))(0, 1, 2, 3, 4, 5, 6, 7) == 7);
|
||||
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _1))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 0);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _2))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 1);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _3))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 2);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _4))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 3);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _5))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 4);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _6))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 5);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _7))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 6);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _8))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 7);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _9))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 8);
|
||||
|
||||
// test mixed perfect forwarding
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _1))(i[0], 1) == 0);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _2))(i[0], 1) == 1);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _1))(0, i[1]) == 0);
|
||||
BOOST_TEST(boost::protect(boost::bind(f, _2))(0, i[1]) == 1);
|
||||
|
||||
// const
|
||||
|
||||
// test nullary
|
||||
BOOST_TEST(constify(constify(boost::protect(boost::bind(f, 1))))() == 1);
|
||||
|
||||
// test lvalues
|
||||
BOOST_TEST(&constify(constify(boost::protect(boost::bind(g, _1))))(i[0]) == &i[0]);
|
||||
|
||||
BOOST_TEST(&constify(constify(boost::protect(boost::bind(g, _1))))(i[0], i[1]) == &i[0]);
|
||||
BOOST_TEST(&constify(constify(boost::protect(boost::bind(g, _2))))(i[0], i[1]) == &i[1]);
|
||||
|
||||
BOOST_TEST(&constify(constify(boost::protect(boost::bind(g, _1))))(i[0], i[1], i[2]) == &i[0]);
|
||||
BOOST_TEST(&constify(constify(boost::protect(boost::bind(g, _2))))(i[0], i[1], i[2]) == &i[1]);
|
||||
BOOST_TEST(&constify(constify(boost::protect(boost::bind(g, _3))))(i[0], i[1], i[2]) == &i[2]);
|
||||
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _1)))(i[0], i[1], i[2], i[3]) == &i[0]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _2)))(i[0], i[1], i[2], i[3]) == &i[1]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _3)))(i[0], i[1], i[2], i[3]) == &i[2]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _4)))(i[0], i[1], i[2], i[3]) == &i[3]);
|
||||
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _1)))(i[0], i[1], i[2], i[3], i[4]) == &i[0]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _2)))(i[0], i[1], i[2], i[3], i[4]) == &i[1]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _3)))(i[0], i[1], i[2], i[3], i[4]) == &i[2]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _4)))(i[0], i[1], i[2], i[3], i[4]) == &i[3]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _5)))(i[0], i[1], i[2], i[3], i[4]) == &i[4]);
|
||||
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _1)))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[0]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _2)))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[1]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _3)))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[2]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _4)))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[3]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _5)))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[4]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _6)))(i[0], i[1], i[2], i[3], i[4], i[5]) == &i[5]);
|
||||
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _1)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[0]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _2)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[1]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _3)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[2]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _4)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[3]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _5)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[4]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _6)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[5]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _7)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]) == &i[6]);
|
||||
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _1)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[0]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _2)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[1]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _3)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[2]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _4)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[3]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _5)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[4]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _6)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[5]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _7)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[6]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _8)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]) == &i[7]);
|
||||
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _1)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[0]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _2)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[1]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _3)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[2]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _4)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[3]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _5)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[4]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _6)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[5]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _7)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[6]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _8)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[7]);
|
||||
BOOST_TEST(&constify(boost::protect(boost::bind(g, _9)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]) == &i[8]);
|
||||
|
||||
// test rvalues
|
||||
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _1)))(0) == 0);
|
||||
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _1)))(0, 1) == 0);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _2)))(0, 1) == 1);
|
||||
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _1)))(0, 1, 2) == 0);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _2)))(0, 1, 2) == 1);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _3)))(0, 1, 2) == 2);
|
||||
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _1)))(0, 1, 2, 3) == 0);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _2)))(0, 1, 2, 3) == 1);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _3)))(0, 1, 2, 3) == 2);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _4)))(0, 1, 2, 3) == 3);
|
||||
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _1)))(0, 1, 2, 3, 4) == 0);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _2)))(0, 1, 2, 3, 4) == 1);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _3)))(0, 1, 2, 3, 4) == 2);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _4)))(0, 1, 2, 3, 4) == 3);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _5)))(0, 1, 2, 3, 4) == 4);
|
||||
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _1)))(0, 1, 2, 3, 4, 5) == 0);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _2)))(0, 1, 2, 3, 4, 5) == 1);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _3)))(0, 1, 2, 3, 4, 5) == 2);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _4)))(0, 1, 2, 3, 4, 5) == 3);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _5)))(0, 1, 2, 3, 4, 5) == 4);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _6)))(0, 1, 2, 3, 4, 5) == 5);
|
||||
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _1)))(0, 1, 2, 3, 4, 5, 6) == 0);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _2)))(0, 1, 2, 3, 4, 5, 6) == 1);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _3)))(0, 1, 2, 3, 4, 5, 6) == 2);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _4)))(0, 1, 2, 3, 4, 5, 6) == 3);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _5)))(0, 1, 2, 3, 4, 5, 6) == 4);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _6)))(0, 1, 2, 3, 4, 5, 6) == 5);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _7)))(0, 1, 2, 3, 4, 5, 6) == 6);
|
||||
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _1)))(0, 1, 2, 3, 4, 5, 6, 7) == 0);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _2)))(0, 1, 2, 3, 4, 5, 6, 7) == 1);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _3)))(0, 1, 2, 3, 4, 5, 6, 7) == 2);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _4)))(0, 1, 2, 3, 4, 5, 6, 7) == 3);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _5)))(0, 1, 2, 3, 4, 5, 6, 7) == 4);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _6)))(0, 1, 2, 3, 4, 5, 6, 7) == 5);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _7)))(0, 1, 2, 3, 4, 5, 6, 7) == 6);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _8)))(0, 1, 2, 3, 4, 5, 6, 7) == 7);
|
||||
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _1)))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 0);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _2)))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 1);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _3)))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 2);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _4)))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 3);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _5)))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 4);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _6)))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 5);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _7)))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 6);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _8)))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 7);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _9)))(0, 1, 2, 3, 4, 5, 6, 7, 8) == 8);
|
||||
|
||||
// test mixed perfect forwarding
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _1)))(i[0], 1) == 0);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _2)))(i[0], 1) == 1);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _1)))(0, i[1]) == 0);
|
||||
BOOST_TEST(constify(boost::protect(boost::bind(f, _2)))(0, i[1]) == 1);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
81
test/ref_fn_test.cpp
Normal file
81
test/ref_fn_test.cpp
Normal file
@@ -0,0 +1,81 @@
|
||||
#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