1
0
forked from boostorg/bind

Merge of new boost.thread code along with required changes from boost.bind

[SVN r46474]
This commit is contained in:
Anthony Williams
2008-06-18 13:01:08 +00:00
parent 224e9f5eec
commit e22e641bbf
10 changed files with 916 additions and 22 deletions

View File

@@ -60,6 +60,7 @@
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_long_form">Inappropriate use of
bind&lt;R&gt;(f, ...)</A></h4>
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_nonstd">Binding a nonstandard function</A></h4>
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_overloaded">Binding an overloaded function</A></h4>
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_const_arg"><b>const</b> in signatures</A></h4>
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_msvc_using">MSVC specific: using
boost::bind;</A></h4>
@@ -188,6 +189,27 @@ bind(std::less&lt;int&gt;(), _1, 9)(x); // x &lt; 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>
@@ -285,21 +307,23 @@ std::for_each(v.begin(), v.end(), bind(apply&lt;void&gt;(), _1, 5));
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 <STRONG>!</STRONG> and the relational operators <STRONG>==</STRONG>,
<STRONG>!=</STRONG>, <STRONG>&lt;</STRONG>, <STRONG>&lt;=</STRONG>, <STRONG>&gt;</STRONG>,
<STRONG>&gt;=</STRONG>.</p>
logical not operator <code>!</code> and the relational and logical operators <code>==</code>,
<code>!=</code>, <code>&lt;</code>, <code>&lt;=</code>, <code>&gt;</code>, <code>&gt;=</code>,
<code>&amp;&amp;</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 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><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( &amp;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( &amp;X::name, _1 ) == "peter" );</tt></P>
<P><tt>std::find_if( first, last, bind( &amp;X::name, _1 ) == "Peter" );</tt></P>
<P><tt>std::find_if( first, last, bind( &amp;X::name, _1 ) == "Peter" || bind(
&amp;X::name, _1 ) == "Paul" );</tt></P>
<P>against a placeholder:</P>
<P><tt>bind( &amp;X::name, _1 ) == _2</tt></P>
<P>or against another <tt>bind</tt> expression:</P>
@@ -362,10 +386,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&lt;class T&gt; void f(T &amp; t);
@@ -373,17 +399,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&lt;class T&gt; void f(T &amp; t);
template&lt;class T&gt; void f(T const &amp; 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>
@@ -528,6 +554,37 @@ 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&amp; get();
int const&amp; get() const;
};
int main()
{
boost::bind( &amp;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&lt; int const&amp; (X::*) () const &gt;( &amp;X::get ), _1 );
}
</pre>
<P>Another, arguably more readable, alternative is to introduce a temporary
variable:</P>
<pre>int main()
{
int const&amp; (X::*get) () const = &amp;X::get;
boost::bind( get, _1 );
}
</pre>
<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:
@@ -859,7 +916,7 @@ namespace
by Jaakko J<>rvi;
<li>
The <a href="../lambda/index.html">Lambda Library</a>
(now part of Boost) by Jaakko J<>rvi and Gary Powell (the successor to the
(now part of Boost) by Jaakko J<>rvi and Gary Powell (the successor to the
Binder Library);
<li>
<a href="http://more.sourceforge.net/">Extensions to the STL</a> by Petter
@@ -890,7 +947,7 @@ namespace
<br>
<br>
<small>Copyright <20> 2001, 2002 by Peter Dimov and Multi Media Ltd. Copyright
2003-2005 Peter Dimov. Distributed under the Boost Software License, Version
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>

View File

@@ -248,6 +248,9 @@ public:
}
};
struct logical_and;
struct logical_or;
template< class A1, class A2 > class list2: private storage2< A1, A2 >
{
private:
@@ -294,6 +297,26 @@ public:
unwrapper<F const>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]);
}
template<class A> bool operator()( type<bool>, logical_and & /*f*/, A & a, int )
{
return a[ base_type::a1_ ] && a[ base_type::a2_ ];
}
template<class A> bool operator()( type<bool>, logical_and const & /*f*/, A & a, int ) const
{
return a[ base_type::a1_ ] && a[ base_type::a2_ ];
}
template<class A> bool operator()( type<bool>, logical_or & /*f*/, A & a, int )
{
return a[ base_type::a1_ ] || a[ base_type::a2_ ];
}
template<class A> bool operator()( type<bool>, logical_or const & /*f*/, A & a, int ) const
{
return a[ base_type::a1_ ] || a[ base_type::a2_ ];
}
template<class V> void accept(V & v) const
{
base_type::accept(v);
@@ -1158,6 +1181,9 @@ BOOST_BIND_OPERATOR( <=, less_equal )
BOOST_BIND_OPERATOR( >, greater )
BOOST_BIND_OPERATOR( >=, greater_equal )
BOOST_BIND_OPERATOR( &&, logical_and )
BOOST_BIND_OPERATOR( ||, logical_or )
#undef BOOST_BIND_OPERATOR
#if defined(__GNUC__) && BOOST_WORKAROUND(__GNUC__, < 3)
@@ -1542,6 +1568,7 @@ template<class F, class A1, class A2, class A3, class A4, class A5, class A6, cl
#define BOOST_BIND_MF_CC
#include <boost/bind/bind_mf_cc.hpp>
#include <boost/bind/bind_mf2_cc.hpp>
#undef BOOST_BIND_MF_NAME
#undef BOOST_BIND_MF_CC
@@ -1552,6 +1579,7 @@ template<class F, class A1, class A2, class A3, class A4, class A5, class A6, cl
#define BOOST_BIND_MF_CC __cdecl
#include <boost/bind/bind_mf_cc.hpp>
#include <boost/bind/bind_mf2_cc.hpp>
#undef BOOST_BIND_MF_NAME
#undef BOOST_BIND_MF_CC
@@ -1564,6 +1592,7 @@ template<class F, class A1, class A2, class A3, class A4, class A5, class A6, cl
#define BOOST_BIND_MF_CC __stdcall
#include <boost/bind/bind_mf_cc.hpp>
#include <boost/bind/bind_mf2_cc.hpp>
#undef BOOST_BIND_MF_NAME
#undef BOOST_BIND_MF_CC
@@ -1576,6 +1605,7 @@ template<class F, class A1, class A2, class A3, class A4, class A5, class A6, cl
#define BOOST_BIND_MF_CC __fastcall
#include <boost/bind/bind_mf_cc.hpp>
#include <boost/bind/bind_mf2_cc.hpp>
#undef BOOST_BIND_MF_NAME
#undef BOOST_BIND_MF_CC

View 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 R2, class R, class T,
class A1>
_bi::bind_t<R2, _mfi::BOOST_BIND_MF_NAME(mf0)<R, T>, typename _bi::list_av_1<A1>::type>
BOOST_BIND(boost::type<R2>, 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<R2, F, list_type>(F(f), list_type(a1));
}
template<class R2, class R, class T,
class A1>
_bi::bind_t<R2, _mfi::BOOST_BIND_MF_NAME(cmf0)<R, T>, typename _bi::list_av_1<A1>::type>
BOOST_BIND(boost::type<R2>, 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<R2, F, list_type>(F(f), list_type(a1));
}
// 1
template<class R2, class R, class T,
class B1,
class A1, class A2>
_bi::bind_t<R2, _mfi::BOOST_BIND_MF_NAME(mf1)<R, T, B1>, typename _bi::list_av_2<A1, A2>::type>
BOOST_BIND(boost::type<R2>, 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<R2, F, list_type>(F(f), list_type(a1, a2));
}
template<class R2, class R, class T,
class B1,
class A1, class A2>
_bi::bind_t<R2, _mfi::BOOST_BIND_MF_NAME(cmf1)<R, T, B1>, typename _bi::list_av_2<A1, A2>::type>
BOOST_BIND(boost::type<R2>, 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<R2, F, list_type>(F(f), list_type(a1, a2));
}
// 2
template<class R2, class R, class T,
class B1, class B2,
class A1, class A2, class A3>
_bi::bind_t<R2, _mfi::BOOST_BIND_MF_NAME(mf2)<R, T, B1, B2>, typename _bi::list_av_3<A1, A2, A3>::type>
BOOST_BIND(boost::type<R2>, 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<R2, F, list_type>(F(f), list_type(a1, a2, a3));
}
template<class R2, class R, class T,
class B1, class B2,
class A1, class A2, class A3>
_bi::bind_t<R2, _mfi::BOOST_BIND_MF_NAME(cmf2)<R, T, B1, B2>, typename _bi::list_av_3<A1, A2, A3>::type>
BOOST_BIND(boost::type<R2>, 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<R2, F, list_type>(F(f), list_type(a1, a2, a3));
}
// 3
template<class R2, class R, class T,
class B1, class B2, class B3,
class A1, class A2, class A3, class A4>
_bi::bind_t<R2, _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<R2>, 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<R2, F, list_type>(F(f), list_type(a1, a2, a3, a4));
}
template<class R2, class R, class T,
class B1, class B2, class B3,
class A1, class A2, class A3, class A4>
_bi::bind_t<R2, _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<R2>, 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<R2, F, list_type>(F(f), list_type(a1, a2, a3, a4));
}
// 4
template<class R2, 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<R2, _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<R2>, 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<R2, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5));
}
template<class R2, 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<R2, _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<R2>, 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<R2, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5));
}
// 5
template<class R2, 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<R2, _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<R2>, 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<R2, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6));
}
template<class R2, 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<R2, _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<R2>, 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<R2, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6));
}
// 6
template<class R2, 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<R2, _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<R2>, 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<R2, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7));
}
template<class R2, 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<R2, _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<R2>, 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<R2, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7));
}
// 7
template<class R2, 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<R2, _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<R2>, 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<R2, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8));
}
template<class R2, 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<R2, _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<R2>, 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<R2, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8));
}
// 8
template<class R2, 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<R2, _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<R2>, 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<R2, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
}
template<class R2, 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<R2, _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<R2>, 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<R2, F, list_type>(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9));
}

View File

@@ -27,10 +27,15 @@ test-suite "bind"
[ 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 ]
;

84
test/bind_and_or_test.cpp Normal file
View 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();
}

171
test/bind_fn2_test.cpp Normal file
View 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
View 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();
}

View File

@@ -1,7 +1,7 @@
//
// bind_lookup_problem_test.cpp
//
// Copyright (C) Markus Sch<EFBFBD>pflin 2005.
// 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

162
test/bind_mf2_test.cpp Normal file
View 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();
}

81
test/ref_fn_test.cpp Normal file
View 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();
}