Boost logo

Boost-Commit :

From: pdimov_at_[hidden]
Date: 2008-05-21 15:49:48


Author: pdimov
Date: 2008-05-21 15:49:47 EDT (Wed, 21 May 2008)
New Revision: 45619
URL: http://svn.boost.org/trac/boost/changeset/45619

Log:
bind( type<R>(), f, ... ) now works when f is a member function.
Added:
   trunk/boost/bind/bind_mf2_cc.hpp (contents, props changed)
   trunk/libs/bind/test/bind_fn2_test.cpp (contents, props changed)
   trunk/libs/bind/test/bind_fnobj2_test.cpp (contents, props changed)
   trunk/libs/bind/test/bind_mf2_test.cpp (contents, props changed)
Text files modified:
   trunk/boost/bind.hpp | 4 ++++
   trunk/libs/bind/test/Jamfile.v2 | 3 +++
   2 files changed, 7 insertions(+), 0 deletions(-)

Modified: trunk/boost/bind.hpp
==============================================================================
--- trunk/boost/bind.hpp (original)
+++ trunk/boost/bind.hpp 2008-05-21 15:49:47 EDT (Wed, 21 May 2008)
@@ -1568,6 +1568,7 @@
 #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
@@ -1578,6 +1579,7 @@
 #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
@@ -1590,6 +1592,7 @@
 #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
@@ -1602,6 +1605,7 @@
 #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

Added: trunk/boost/bind/bind_mf2_cc.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/bind/bind_mf2_cc.hpp 2008-05-21 15:49:47 EDT (Wed, 21 May 2008)
@@ -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));
+}

Modified: trunk/libs/bind/test/Jamfile.v2
==============================================================================
--- trunk/libs/bind/test/Jamfile.v2 (original)
+++ trunk/libs/bind/test/Jamfile.v2 2008-05-21 15:49:47 EDT (Wed, 21 May 2008)
@@ -35,4 +35,7 @@
       [ 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 ]
     ;

Added: trunk/libs/bind/test/bind_fn2_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/bind/test/bind_fn2_test.cpp 2008-05-21 15:49:47 EDT (Wed, 21 May 2008)
@@ -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();
+}

Added: trunk/libs/bind/test/bind_fnobj2_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/bind/test/bind_fnobj2_test.cpp 2008-05-21 15:49:47 EDT (Wed, 21 May 2008)
@@ -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();
+}

Added: trunk/libs/bind/test/bind_mf2_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/bind/test/bind_mf2_test.cpp 2008-05-21 15:49:47 EDT (Wed, 21 May 2008)
@@ -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();
+}


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk