From 683d699e4a00c6bb35ec3ff7f2da358f332f7700 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 21 Apr 2006 11:55:39 +0000 Subject: [PATCH 01/62] Added diagnostic output. [SVN r33754] --- test/bind_visit_test.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/bind_visit_test.cpp b/test/bind_visit_test.cpp index c2b8089..5fd8e88 100644 --- a/test/bind_visit_test.cpp +++ b/test/bind_visit_test.cpp @@ -22,6 +22,7 @@ #endif #include +#include #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) # pragma warning(pop) @@ -37,12 +38,14 @@ struct visitor { } - template void operator()( T const & /*t*/ ) + template 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; } }; From c69a4ad382a202fffb74913ee089b10f3c4bcca1 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 21 Apr 2006 13:14:58 +0000 Subject: [PATCH 02/62] Fixed a visit_each-related bug exposed by strict two-phase lookup [SVN r33761] --- include/boost/bind.hpp | 31 +++++++++++++++++++++++----- include/boost/bind/bind_template.hpp | 5 +++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/include/boost/bind.hpp b/include/boost/bind.hpp index bd14c1d..bece8a7 100644 --- a/include/boost/bind.hpp +++ b/include/boost/bind.hpp @@ -1159,20 +1159,41 @@ BOOST_BIND_OPERATOR( >=, greater_equal ) #endif +// visit_each, ADL + +#if !defined( BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP ) && !defined( __BORLANDC__ ) + +template void visit_each( V & v, value const & t, int ) +{ + using boost::visit_each; + BOOST_BIND_VISIT_EACH( v, t.get(), 0 ); +} + +template void visit_each( V & v, bind_t const & t, int ) +{ + t.accept( v ); +} + +#endif + } // namespace _bi -// visit_each +// visit_each, no ADL -template void visit_each(V & v, _bi::value const & t, int) +#if defined( BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP ) || defined( __BORLANDC__ ) + +template void visit_each( V & v, _bi::value const & t, int ) { - BOOST_BIND_VISIT_EACH(v, t.get(), 0); + BOOST_BIND_VISIT_EACH( v, t.get(), 0 ); } -template void visit_each(V & v, _bi::bind_t const & t, int) +template void visit_each( V & v, _bi::bind_t const & t, int ) { - t.accept(v); + t.accept( v ); } +#endif + // bind #ifndef BOOST_BIND diff --git a/include/boost/bind/bind_template.hpp b/include/boost/bind/bind_template.hpp index 5aac196..b2c295d 100644 --- a/include/boost/bind/bind_template.hpp +++ b/include/boost/bind/bind_template.hpp @@ -206,6 +206,11 @@ template 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); } From bfe10df38aa9a07a4eceb460f13780d33be9dd62 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 6 Jul 2006 13:47:26 +0000 Subject: [PATCH 03/62] is_placeholder, is_bind_expression added. [SVN r34468] --- include/boost/bind.hpp | 38 ++++++++++++++++ include/boost/bind/arg.hpp | 30 +++++++++++- include/boost/is_placeholder.hpp | 31 +++++++++++++ test/Jamfile | 1 + test/Jamfile.v2 | 1 + test/bind_placeholder_test.cpp | 78 ++++++++++++++++++++++++++++++++ 6 files changed, 177 insertions(+), 2 deletions(-) create mode 100644 include/boost/is_placeholder.hpp create mode 100644 test/bind_placeholder_test.cpp diff --git a/include/boost/bind.hpp b/include/boost/bind.hpp index bece8a7..0ecb8bc 100644 --- a/include/boost/bind.hpp +++ b/include/boost/bind.hpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -933,11 +934,32 @@ namespace _bi #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || (__SUNPRO_CC >= 0x530) +#if 0 + template struct add_value { typedef _bi::value type; }; +#else + +template< class T, int I > struct add_value_2 +{ + typedef boost::arg type; +}; + +template< class T > struct add_value_2< T, 0 > +{ + typedef _bi::value< T > type; +}; + +template struct add_value +{ + typedef typename add_value_2< T, boost::is_placeholder< T >::value >::type type; +}; + +#endif + template struct add_value< value > { typedef _bi::value type; @@ -1194,6 +1216,22 @@ template void visit_each( V & v, _bi::bind_t #endif +// is_bind_expression + +template< class T > struct is_bind_expression +{ + enum _vt { value = 0 }; +}; + +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +template< class R, class F, class L > struct is_bind_expression< _bi::bind_t< R, F, L > > +{ + enum _vt { value = 1 }; +}; + +#endif + // bind #ifndef BOOST_BIND diff --git a/include/boost/bind/arg.hpp b/include/boost/bind/arg.hpp index 90e966e..0d5cd03 100644 --- a/include/boost/bind/arg.hpp +++ b/include/boost/bind/arg.hpp @@ -19,18 +19,44 @@ // See http://www.boost.org/libs/bind/bind.html for documentation. // +#include +#include + namespace boost { -template class arg +template< int I > struct arg { + arg() + { + } + + template< class T > arg( T const & /* t */ ) + { + // static assert I == is_placeholder::value + typedef char T_must_be_placeholder[ I == is_placeholder::value? 1: -1 ]; + } }; -template bool operator==(arg const &, arg const &) +template< int I > bool operator==( arg const &, arg const & ) { return true; } +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +template< int I > struct is_placeholder< arg > +{ + enum _vt { value = I }; +}; + +template< int I > struct is_placeholder< arg (*) () > +{ + enum _vt { value = I }; +}; + +#endif + } // namespace boost #endif // #ifndef BOOST_BIND_ARG_HPP_INCLUDED diff --git a/include/boost/is_placeholder.hpp b/include/boost/is_placeholder.hpp new file mode 100644 index 0000000..5f1b544 --- /dev/null +++ b/include/boost/is_placeholder.hpp @@ -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 diff --git a/test/Jamfile b/test/Jamfile index 9cb627c..39bfe7b 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -32,6 +32,7 @@ DEPENDS all : bind ; [ compile bind_unary_addr.cpp ] [ run bind_dm3_test.cpp ] [ run bind_visit_test.cpp ] + [ run bind_placeholder_test.cpp ] [ run mem_fn_test.cpp ] [ run mem_fn_void_test.cpp ] [ run mem_fn_derived_test.cpp ] diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 170166b..8b15a58 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -26,6 +26,7 @@ test-suite "bind" [ compile bind_unary_addr.cpp ] [ run bind_dm3_test.cpp ] [ run bind_visit_test.cpp ] + [ run bind_placeholder_test.cpp ] [ run mem_fn_test.cpp ] [ run mem_fn_void_test.cpp ] [ run mem_fn_derived_test.cpp ] diff --git a/test/bind_placeholder_test.cpp b/test/bind_placeholder_test.cpp new file mode 100644 index 0000000..90ba2dd --- /dev/null +++ b/test/bind_placeholder_test.cpp @@ -0,0 +1,78 @@ +#include + +#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 + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include + +// + +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 +{ +}; + +template< int I > struct boost::is_placeholder< custom_placeholder< I > > +{ + enum { value = I }; +}; + +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(); +} From b272145f3eb1d8d85545b6585c463a5cd7f478ca Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 7 Jul 2006 19:09:16 +0000 Subject: [PATCH 04/62] Moved the specialization into namespace boost [SVN r34477] --- test/bind_placeholder_test.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/bind_placeholder_test.cpp b/test/bind_placeholder_test.cpp index 90ba2dd..174dd82 100644 --- a/test/bind_placeholder_test.cpp +++ b/test/bind_placeholder_test.cpp @@ -43,11 +43,16 @@ template< int I > struct custom_placeholder { }; -template< int I > struct boost::is_placeholder< custom_placeholder< I > > +namespace boost +{ + +template< int I > struct is_placeholder< custom_placeholder< I > > { enum { value = I }; }; +} // namespace boost + int main() { int const x1 = 1; From 0cc198acc202f415cb11bb7e718b3269c6bcbb9f Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 20 Sep 2006 13:07:20 +0000 Subject: [PATCH 05/62] Work around ADL bug in GCC 3.3 that is causing failures in the Signals library [SVN r35224] --- include/boost/bind.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/boost/bind.hpp b/include/boost/bind.hpp index 0ecb8bc..f8c58db 100644 --- a/include/boost/bind.hpp +++ b/include/boost/bind.hpp @@ -1183,7 +1183,8 @@ BOOST_BIND_OPERATOR( >=, greater_equal ) // visit_each, ADL -#if !defined( BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP ) && !defined( __BORLANDC__ ) +#if !defined( BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP ) && !defined( __BORLANDC__ ) \ + && !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3) template void visit_each( V & v, value const & t, int ) { @@ -1202,7 +1203,8 @@ template void visit_each( V & v, bind_t void visit_each( V & v, _bi::value const & t, int ) { From 0aadd1805d028c3989d58875c919b24f06580f91 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 16 Oct 2006 19:11:29 +0000 Subject: [PATCH 06/62] Rvalue overloads (suggested by Herve Bronnimann) [SVN r35640] --- include/boost/bind/bind_template.hpp | 119 +++++++++++++++++++++++++++ test/Jamfile | 1 + test/Jamfile.v2 | 1 + test/bind_rvalue_test.cpp | 81 ++++++++++++++++++ 4 files changed, 202 insertions(+) create mode 100644 test/bind_rvalue_test.cpp diff --git a/include/boost/bind/bind_template.hpp b/include/boost/bind/bind_template.hpp index b2c295d..411d20c 100644 --- a/include/boost/bind/bind_template.hpp +++ b/include/boost/bind/bind_template.hpp @@ -122,6 +122,23 @@ BOOST_BIND_RETURN l_(type(), f_, a, 0); } +#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \ + && !BOOST_WORKAROUND(__EDG_VERSION__, <= 238) + + template result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3) + { + list3 a(a1, a2, a3); + BOOST_BIND_RETURN l_(type(), f_, a, 0); + } + + template result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3) const + { + list3 a(a1, a2, a3); + BOOST_BIND_RETURN l_(type(), f_, a, 0); + } + +#endif + template result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4) { list4 a(a1, a2, a3, a4); @@ -134,6 +151,23 @@ BOOST_BIND_RETURN l_(type(), f_, a, 0); } +#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \ + && !BOOST_WORKAROUND(__EDG_VERSION__, <= 238) + + template result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4) + { + list4 a(a1, a2, a3, a4); + BOOST_BIND_RETURN l_(type(), f_, a, 0); + } + + template result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4) const + { + list4 a(a1, a2, a3, a4); + BOOST_BIND_RETURN l_(type(), f_, a, 0); + } + +#endif + template result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5) { list5 a(a1, a2, a3, a4, a5); @@ -146,6 +180,23 @@ BOOST_BIND_RETURN l_(type(), f_, a, 0); } +#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \ + && !BOOST_WORKAROUND(__EDG_VERSION__, <= 238) + + template result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5) + { + list5 a(a1, a2, a3, a4, a5); + BOOST_BIND_RETURN l_(type(), f_, a, 0); + } + + template result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5) const + { + list5 a(a1, a2, a3, a4, a5); + BOOST_BIND_RETURN l_(type(), f_, a, 0); + } + +#endif + template result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6) { list6 a(a1, a2, a3, a4, a5, a6); @@ -158,6 +209,23 @@ BOOST_BIND_RETURN l_(type(), f_, a, 0); } +#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \ + && !BOOST_WORKAROUND(__EDG_VERSION__, <= 238) + + template result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6) + { + list6 a(a1, a2, a3, a4, a5, a6); + BOOST_BIND_RETURN l_(type(), f_, a, 0); + } + + template result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6) const + { + list6 a(a1, a2, a3, a4, a5, a6); + BOOST_BIND_RETURN l_(type(), f_, a, 0); + } + +#endif + template result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7) { list7 a(a1, a2, a3, a4, a5, a6, a7); @@ -170,6 +238,23 @@ BOOST_BIND_RETURN l_(type(), f_, a, 0); } +#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \ + && !BOOST_WORKAROUND(__EDG_VERSION__, <= 238) + + template 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 a(a1, a2, a3, a4, a5, a6, a7); + BOOST_BIND_RETURN l_(type(), f_, a, 0); + } + + template 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 a(a1, a2, a3, a4, a5, a6, a7); + BOOST_BIND_RETURN l_(type(), f_, a, 0); + } + +#endif + template result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8) { list8 a(a1, a2, a3, a4, a5, a6, a7, a8); @@ -182,6 +267,23 @@ BOOST_BIND_RETURN l_(type(), f_, a, 0); } +#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \ + && !BOOST_WORKAROUND(__EDG_VERSION__, <= 238) + + template 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 a(a1, a2, a3, a4, a5, a6, a7, a8); + BOOST_BIND_RETURN l_(type(), f_, a, 0); + } + + template 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 a(a1, a2, a3, a4, a5, a6, a7, a8); + BOOST_BIND_RETURN l_(type(), f_, a, 0); + } + +#endif + template result_type operator()(A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8, A9 & a9) { list9 a(a1, a2, a3, a4, a5, a6, a7, a8, a9); @@ -194,6 +296,23 @@ BOOST_BIND_RETURN l_(type(), f_, a, 0); } +#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \ + && !BOOST_WORKAROUND(__EDG_VERSION__, <= 238) + + template 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 a(a1, a2, a3, a4, a5, a6, a7, a8, a9); + BOOST_BIND_RETURN l_(type(), f_, a, 0); + } + + template 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 a(a1, a2, a3, a4, a5, a6, a7, a8, a9); + BOOST_BIND_RETURN l_(type(), f_, a, 0); + } + +#endif + template result_type eval(A & a) { BOOST_BIND_RETURN l_(type(), f_, a, 0); diff --git a/test/Jamfile b/test/Jamfile index 39bfe7b..f6dd747 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -33,6 +33,7 @@ DEPENDS all : bind ; [ run bind_dm3_test.cpp ] [ run bind_visit_test.cpp ] [ run bind_placeholder_test.cpp ] + [ run bind_rvalue_test.cpp ] [ run mem_fn_test.cpp ] [ run mem_fn_void_test.cpp ] [ run mem_fn_derived_test.cpp ] diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 8b15a58..ed8ec80 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -27,6 +27,7 @@ test-suite "bind" [ run bind_dm3_test.cpp ] [ run bind_visit_test.cpp ] [ run bind_placeholder_test.cpp ] + [ run bind_rvalue_test.cpp ] [ run mem_fn_test.cpp ] [ run mem_fn_void_test.cpp ] [ run mem_fn_derived_test.cpp ] diff --git a/test/bind_rvalue_test.cpp b/test/bind_rvalue_test.cpp new file mode 100644 index 0000000..e0bd229 --- /dev/null +++ b/test/bind_rvalue_test.cpp @@ -0,0 +1,81 @@ +#include + +#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 + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include + +// + +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(); +} From a695360c4f6224a1c41f4b578b11fb4258d4615e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 18 Oct 2006 17:36:50 +0000 Subject: [PATCH 07/62] Borland fix [SVN r35661] --- include/boost/bind.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/bind.hpp b/include/boost/bind.hpp index f8c58db..e1076e0 100644 --- a/include/boost/bind.hpp +++ b/include/boost/bind.hpp @@ -934,7 +934,7 @@ namespace _bi #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || (__SUNPRO_CC >= 0x530) -#if 0 +#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x582) ) template struct add_value { From c746cf26de8df970763bf073f7a86260a81d6cfd Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Tue, 7 Nov 2006 19:11:57 +0000 Subject: [PATCH 08/62] Add copyright, license [SVN r35905] --- index.html | 8 +- mem_fn.html | 419 ++-------------------------------------------------- 2 files changed, 19 insertions(+), 408 deletions(-) diff --git a/index.html b/index.html index c53b817..b1b9399 100644 --- a/index.html +++ b/index.html @@ -5,6 +5,10 @@ Automatic redirection failed, please go to bind.html or -mem_fn.html. +mem_fn.html
+

© Copyright Beman Dawes, 2001

+

Distributed under the Boost Software License, Version 1.0. (See accompanying +file LICENSE_1_0.txt or copy +at www.boost.org/LICENSE_1_0.txt)

- + \ No newline at end of file diff --git a/mem_fn.html b/mem_fn.html index 5cc89f2..f04a667 100644 --- a/mem_fn.html +++ b/mem_fn.html @@ -1,407 +1,14 @@ - - - Boost: mem_fn.hpp documentation - - - - - - - - - - - -
boost.png (6897 bytes) - -

mem_fn.hpp

-
 
-

Contents

-

Purpose

-

Frequently Asked Questions

-

Can mem_fn be used instead of the - standard std::mem_fun[_ref] adaptors?

-

Should I replace every occurence of std::mem_fun[_ref] - with mem_fn in my existing code?

-

Does mem_fn work with COM methods?

-

Why isn't BOOST_MEM_FN_ENABLE_STDCALL - defined automatically?

-

Interface

-

Synopsis

-

Common requirements

-

get_pointer

-

mem_fn

-

Implementation

-

Files

-

Dependencies

-

Number of Arguments

-

"__stdcall", "__cdecl" and - "__fastcall" Support

-

Acknowledgements

-

Purpose

-

- boost::mem_fn is a generalization of the standard functions std::mem_fun - and std::mem_fun_ref. It supports member function pointers with more - than one argument, and the returned function object can take a pointer, a - reference, or a smart pointer to an object instance as its first argument. mem_fn - also supports pointers to data members by treating them as functions taking no - arguments and returning a (const) reference to the member. -

-

- The purpose of mem_fn is twofold. First, it allows users to invoke a - member function on a container with the familiar -

-
-    std::for_each(v.begin(), v.end(), boost::mem_fn(&Shape::draw));
-
-

- syntax, even when the container stores smart pointers. -

-

- Second, it can be used as a building block by library developers that want to - treat a pointer to member function as a function object. A library might define - an enhanced for_each algorithm with an overload of the form: -

-
-template<class It, class R, class T> void for_each(It first, It last, R (T::*pmf) ())
-{
-    std::for_each(first, last, boost::mem_fn(pmf));
-}
-
-

- that will allow the convenient syntax: -

-
-    for_each(v.begin(), v.end(), &Shape::draw);
-
-

- When documenting the feature, the library author will simply state: -

-

template<class It, class R, class T> void - for_each(It first, It last, R (T::*pmf) ());

-

- Effects: equivalent to std::for_each(first, last, boost::mem_fn(pmf)); -

-

- where boost::mem_fn can be a link to this page. See the - documentation of bind for an example. -

-

- mem_fn takes one argument, a pointer to a member, and returns a function - object suitable for use with standard or user-defined algorithms: -

-
-struct X
-{
-    void f();
-};
-
-void g(std::vector<X> & v)
-{
-    std::for_each(v.begin(), v.end(), boost::mem_fn(&X::f));
-};
-
-void h(std::vector<X *> const & v)
-{
-    std::for_each(v.begin(), v.end(), boost::mem_fn(&X::f));
-};
-
-void k(std::vector<boost::shared_ptr<X> > const & v)
-{
-    std::for_each(v.begin(), v.end(), boost::mem_fn(&X::f));
-};
-
-

- The returned function object takes the same arguments as the input member - function plus a "flexible" first argument that represents the object instance. -

-

- When the function object is invoked with a first argument x that is - neither a pointer nor a reference to the appropriate class (X in the - example above), it uses get_pointer(x) to obtain a pointer from x. - Library authors can "register" their smart pointer classes by supplying an - appropriate get_pointer overload, allowing mem_fn to recognize - and support them. -

-

- [Note: get_pointer is not restricted to return a pointer. Any object - that can be used in a member function call expression (x->*pmf)(...) - will work.] -

-

- [Note: the library uses an unqualified call to get_pointer. Therefore, - it will find, through argument-dependent lookup, get_pointer overloads - that are defined in the same namespace as the corresponding smart pointer - class, in addition to any boost::get_pointer overloads.] -

-

- All function objects returned by mem_fn expose a result_type typedef - that represents the return type of the member function. For data members, result_type - is defined as the type of the member. -

-

Frequently Asked Questions

-

Can mem_fn be used instead of the standard std::mem_fun[_ref] - adaptors?

-

- Yes. For simple uses, mem_fn provides additional functionality that the - standard adaptors do not. Complicated expressions that use std::bind1st, std::bind2nd - or Boost.Compose along with the - standard adaptors can be rewritten using boost::bind - that automatically takes advantage of mem_fn. -

-

Should I replace every occurence of std::mem_fun[_ref] with mem_fn - in my existing code?

-

- No, unless you have good reasons to do so. mem_fn is not 100% compatible - with the standard adaptors, although it comes pretty close. In particular, mem_fn - does not return objects of type std::[const_]mem_fun[1][_ref]_t, as the - standard adaptors do, and it is not possible to fully describe the type of the - first argument using the standard argument_type and first_argument_type - nested typedefs. Libraries that need adaptable function objects in order to - function might not like mem_fn. -

-

Does mem_fn work with COM methods?

-

- Yes, if you #define BOOST_MEM_FN_ENABLE_STDCALL. -

-

Why isn't BOOST_MEM_FN_ENABLE_STDCALL defined automatically?

-

- Non-portable extensions, in general, should default to off to prevent vendor - lock-in. Had BOOST_MEM_FN_ENABLE_STDCALL been defined automatically, you could - have accidentally taken advantage of it without realizing that your code is, - perhaps, no longer portable. In addition, it is possible for the default - calling convention to be __stdcall, in which case enabling __stdcall support - will result in duplicate definitions. -

-

Interface

-

Synopsis

-
-namespace boost
-{
-
-template<class T> T * get_pointer(T * p);
-
-template<class R, class T> unspecified-1 mem_fn(R (T::*pmf) ());
-
-template<class R, class T> unspecified-2 mem_fn(R (T::*pmf) () const);
-
-template<class R, class T> unspecified-2-1 mem_fn(R T::*pm);
-
-template<class R, class T, class A1> unspecified-3 mem_fn(R (T::*pmf) (A1));
-
-template<class R, class T, class A1> unspecified-4 mem_fn(R (T::*pmf) (A1) const);
-
-template<class R, class T, class A1, class A2> unspecified-5 mem_fn(R (T::*pmf) (A1, A2));
-
-template<class R, class T, class A1, class A2> unspecified-6 mem_fn(R (T::*pmf) (A1, A2) const);
-
-// implementation defined number of additional overloads for more arguments
-
-}
-
-

Common requirements

-

- All unspecified-N types mentioned in the Synopsis are CopyConstructible - and Assignable. Their copy constructors and assignment operators do not - throw exceptions. unspecified-N::result_type is defined as the - return type of the member function pointer passed as an argument to mem_fn - (R in the Synopsis.) unspecified-2-1::result_type is - defined as R. -

-

get_pointer

-

template<class T> T * get_pointer(T * p)

-
-

- Returns: p. -

-

- Throws: Nothing. -

-
-

mem_fn

-

template<class R, class T> unspecified-1 mem_fn(R - (T::*pmf) ())

-
-

- Returns: a function object f such that the expression f(t) - is equivalent to (t.*pmf)() when t is an l-value of type T - or derived, (get_pointer(t)->*pmf)() otherwise. -

-

- Throws: Nothing. -

-
-

template<class R, class T> unspecified-2 mem_fn(R - (T::*pmf) () const)

-
-

- Returns: a function object f such that the expression f(t) - is equivalent to (t.*pmf)() when t is of type T - [const] or derived, (get_pointer(t)->*pmf)() - otherwise. -

-

- Throws: Nothing. -

-
-

template<class R, class T> unspecified-2-1 mem_fn(R - T::*pm)

-
-

- Returns: a function object f such that the expression f(t) - is equivalent to t.*pm when t is of type T [const] - or derived, get_pointer(t)->*pm otherwise. -

-

- Throws: Nothing. -

-
-

template<class R, class T, class A1> unspecified-3 mem_fn(R - (T::*pmf) (A1))

-
-

- Returns: a function object f such that the expression f(t, a1) - is equivalent to (t.*pmf)(a1) when t is an l-value of type T - or derived, (get_pointer(t)->*pmf)(a1) otherwise. -

-

- Throws: Nothing. -

-
-

template<class R, class T, class A1> unspecified-4 mem_fn(R - (T::*pmf) (A1) const)

-
-

- Returns: a function object f such that the expression f(t, a1) - is equivalent to (t.*pmf)(a1) when t is of type T - [const] or derived, (get_pointer(t)->*pmf)(a1) - otherwise. -

-

- Throws: Nothing. -

-
-

template<class R, class T, class A1, class A2> unspecified-5 - mem_fn(R (T::*pmf) (A1, A2))

-
-

- Returns: a function object f such that the expression f(t, a1, a2) - is equivalent to (t.*pmf)(a1, a2) when t is an l-value of type - T or derived, (get_pointer(t)->*pmf)(a1, a2) otherwise. -

-

- Throws: Nothing. -

-
-

template<class R, class T, class A1, class A2> unspecified-6 - mem_fn(R (T::*pmf) (A1, A2) const)

-
-

- Returns: a function object f such that the expression f(t, a1, a2) - is equivalent to (t.*pmf)(a1, a2) when t is of type T - [const] or derived, (get_pointer(t)->*pmf)(a1, a2) otherwise. -

-

- Throws: Nothing. -

-
-

Implementation

-

Files

- -

Dependencies

- -

Number of Arguments

-

- This implementation supports member functions with up to eight arguments. This - is not an inherent limitation of the design, but an implementation detail. -

-

"__stdcall", "__cdecl" and "__fastcall" Support

-

- Some platforms allow several types of member functions that differ by their calling - convention (the rules by which the function is invoked: how are - arguments passed, how is the return value handled, and who cleans up the stack - - if any.) -

-

- For example, Windows API functions and COM interface member functions use a - calling convention known as __stdcall. Borland VCL components use __fastcall. - UDK, the component model of OpenOffice.org, uses __cdecl. -

-

- To use mem_fn with __stdcall member functions, #define the - macro BOOST_MEM_FN_ENABLE_STDCALL before including, directly or - indirectly, <boost/mem_fn.hpp>. -

-

To use mem_fn with __fastcall member functions, #define the - macro BOOST_MEM_FN_ENABLE_FASTCALL before including <boost/mem_fn.hpp>. -

-

To use mem_fn with __cdecl member functions, #define the - macro BOOST_MEM_FN_ENABLE_CDECL before including <boost/mem_fn.hpp>. -

-

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. Not following this rule can lead to obscure errors - when a header includes mem_fn.hpp before the macro has been defined.

-

[Note: this is a non-portable extension. It is not part of the interface.] -

-

- [Note: Some compilers provide only minimal support for the __stdcall keyword.] -

-

Acknowledgements

-

- Rene Jager's initial suggestion of using traits classes to make mem_fn adapt - to user-defined smart pointers inspired the get_pointer-based design. -

-

- Numerous improvements were suggested during the formal review period by Richard - Crossley, Jens Maurer, Ed Brey, and others. Review manager was Darin Adler. -

-

- Steve Anichini pointed out that COM interfaces use __stdcall. -

-

- Dave Abrahams modified bind and mem_fn to support void returns on - deficient compilers. -

-

Daniel Boelzle pointed out that UDK uses __cdecl.
-
-
- Copyright © 2001, 2002 by Peter Dimov and Multi Media Ltd. Copyright - 2003-2005 Peter Dimov. 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.

- - + + + + +Automatic redirection failed, please go to +../bind/mem_fn.html
+

© Copyright Beman Dawes, 2001

+

Distributed under the Boost Software License, Version 1.0. (See accompanying +file LICENSE_1_0.txt or copy +at www.boost.org/LICENSE_1_0.txt)

+

 

+ + \ No newline at end of file From 2f595f53f50cf02c71e752bb94a314adba18f177 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 9 Nov 2006 19:29:42 +0000 Subject: [PATCH 09/62] License/copyright edits [SVN r35954] --- bind.html | 7 +- index.html | 14 +- mem_fn.html | 418 ++++++++++++++++++++++++++++++++++++++++++++++-- ref.html | 6 + test/Jamfile | 7 +- test/Jamfile.v2 | 7 +- 6 files changed, 428 insertions(+), 31 deletions(-) diff --git a/bind.html b/bind.html index 844af7f..83794be 100644 --- a/bind.html +++ b/bind.html @@ -890,9 +890,8 @@ namespace

Copyright © 2001, 2002 by Peter Dimov and Multi Media Ltd. Copyright - 2003-2005 Peter Dimov. 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.

+ 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.

diff --git a/index.html b/index.html index b1b9399..b3f0d25 100644 --- a/index.html +++ b/index.html @@ -5,10 +5,12 @@ Automatic redirection failed, please go to bind.html or -mem_fn.html
-

© Copyright Beman Dawes, 2001

-

Distributed under the Boost Software License, Version 1.0. (See accompanying -file LICENSE_1_0.txt or copy -at www.boost.org/LICENSE_1_0.txt)

+mem_fn.html. - \ No newline at end of file + + diff --git a/mem_fn.html b/mem_fn.html index f04a667..1ec8f1e 100644 --- a/mem_fn.html +++ b/mem_fn.html @@ -1,14 +1,406 @@ + - - - - -Automatic redirection failed, please go to -../bind/mem_fn.html
-

© Copyright Beman Dawes, 2001

-

Distributed under the Boost Software License, Version 1.0. (See accompanying -file LICENSE_1_0.txt or copy -at www.boost.org/LICENSE_1_0.txt)

-

 

- - \ No newline at end of file + + Boost: mem_fn.hpp documentation + + + + + + + + + + + +
boost.png (6897 bytes) + +

mem_fn.hpp

+
 
+

Contents

+

Purpose

+

Frequently Asked Questions

+

Can mem_fn be used instead of the + standard std::mem_fun[_ref] adaptors?

+

Should I replace every occurence of std::mem_fun[_ref] + with mem_fn in my existing code?

+

Does mem_fn work with COM methods?

+

Why isn't BOOST_MEM_FN_ENABLE_STDCALL + defined automatically?

+

Interface

+

Synopsis

+

Common requirements

+

get_pointer

+

mem_fn

+

Implementation

+

Files

+

Dependencies

+

Number of Arguments

+

"__stdcall", "__cdecl" and + "__fastcall" Support

+

Acknowledgements

+

Purpose

+

+ boost::mem_fn is a generalization of the standard functions std::mem_fun + and std::mem_fun_ref. It supports member function pointers with more + than one argument, and the returned function object can take a pointer, a + reference, or a smart pointer to an object instance as its first argument. mem_fn + also supports pointers to data members by treating them as functions taking no + arguments and returning a (const) reference to the member. +

+

+ The purpose of mem_fn is twofold. First, it allows users to invoke a + member function on a container with the familiar +

+
+    std::for_each(v.begin(), v.end(), boost::mem_fn(&Shape::draw));
+
+

+ syntax, even when the container stores smart pointers. +

+

+ Second, it can be used as a building block by library developers that want to + treat a pointer to member function as a function object. A library might define + an enhanced for_each algorithm with an overload of the form: +

+
+template<class It, class R, class T> void for_each(It first, It last, R (T::*pmf) ())
+{
+    std::for_each(first, last, boost::mem_fn(pmf));
+}
+
+

+ that will allow the convenient syntax: +

+
+    for_each(v.begin(), v.end(), &Shape::draw);
+
+

+ When documenting the feature, the library author will simply state: +

+

template<class It, class R, class T> void + for_each(It first, It last, R (T::*pmf) ());

+

+ Effects: equivalent to std::for_each(first, last, boost::mem_fn(pmf)); +

+

+ where boost::mem_fn can be a link to this page. See the + documentation of bind for an example. +

+

+ mem_fn takes one argument, a pointer to a member, and returns a function + object suitable for use with standard or user-defined algorithms: +

+
+struct X
+{
+    void f();
+};
+
+void g(std::vector<X> & v)
+{
+    std::for_each(v.begin(), v.end(), boost::mem_fn(&X::f));
+};
+
+void h(std::vector<X *> const & v)
+{
+    std::for_each(v.begin(), v.end(), boost::mem_fn(&X::f));
+};
+
+void k(std::vector<boost::shared_ptr<X> > const & v)
+{
+    std::for_each(v.begin(), v.end(), boost::mem_fn(&X::f));
+};
+
+

+ The returned function object takes the same arguments as the input member + function plus a "flexible" first argument that represents the object instance. +

+

+ When the function object is invoked with a first argument x that is + neither a pointer nor a reference to the appropriate class (X in the + example above), it uses get_pointer(x) to obtain a pointer from x. + Library authors can "register" their smart pointer classes by supplying an + appropriate get_pointer overload, allowing mem_fn to recognize + and support them. +

+

+ [Note: get_pointer is not restricted to return a pointer. Any object + that can be used in a member function call expression (x->*pmf)(...) + will work.] +

+

+ [Note: the library uses an unqualified call to get_pointer. Therefore, + it will find, through argument-dependent lookup, get_pointer overloads + that are defined in the same namespace as the corresponding smart pointer + class, in addition to any boost::get_pointer overloads.] +

+

+ All function objects returned by mem_fn expose a result_type typedef + that represents the return type of the member function. For data members, result_type + is defined as the type of the member. +

+

Frequently Asked Questions

+

Can mem_fn be used instead of the standard std::mem_fun[_ref] + adaptors?

+

+ Yes. For simple uses, mem_fn provides additional functionality that the + standard adaptors do not. Complicated expressions that use std::bind1st, std::bind2nd + or Boost.Compose along with the + standard adaptors can be rewritten using boost::bind + that automatically takes advantage of mem_fn. +

+

Should I replace every occurence of std::mem_fun[_ref] with mem_fn + in my existing code?

+

+ No, unless you have good reasons to do so. mem_fn is not 100% compatible + with the standard adaptors, although it comes pretty close. In particular, mem_fn + does not return objects of type std::[const_]mem_fun[1][_ref]_t, as the + standard adaptors do, and it is not possible to fully describe the type of the + first argument using the standard argument_type and first_argument_type + nested typedefs. Libraries that need adaptable function objects in order to + function might not like mem_fn. +

+

Does mem_fn work with COM methods?

+

+ Yes, if you #define BOOST_MEM_FN_ENABLE_STDCALL. +

+

Why isn't BOOST_MEM_FN_ENABLE_STDCALL defined automatically?

+

+ Non-portable extensions, in general, should default to off to prevent vendor + lock-in. Had BOOST_MEM_FN_ENABLE_STDCALL been defined automatically, you could + have accidentally taken advantage of it without realizing that your code is, + perhaps, no longer portable. In addition, it is possible for the default + calling convention to be __stdcall, in which case enabling __stdcall support + will result in duplicate definitions. +

+

Interface

+

Synopsis

+
+namespace boost
+{
+
+template<class T> T * get_pointer(T * p);
+
+template<class R, class T> unspecified-1 mem_fn(R (T::*pmf) ());
+
+template<class R, class T> unspecified-2 mem_fn(R (T::*pmf) () const);
+
+template<class R, class T> unspecified-2-1 mem_fn(R T::*pm);
+
+template<class R, class T, class A1> unspecified-3 mem_fn(R (T::*pmf) (A1));
+
+template<class R, class T, class A1> unspecified-4 mem_fn(R (T::*pmf) (A1) const);
+
+template<class R, class T, class A1, class A2> unspecified-5 mem_fn(R (T::*pmf) (A1, A2));
+
+template<class R, class T, class A1, class A2> unspecified-6 mem_fn(R (T::*pmf) (A1, A2) const);
+
+// implementation defined number of additional overloads for more arguments
+
+}
+
+

Common requirements

+

+ All unspecified-N types mentioned in the Synopsis are CopyConstructible + and Assignable. Their copy constructors and assignment operators do not + throw exceptions. unspecified-N::result_type is defined as the + return type of the member function pointer passed as an argument to mem_fn + (R in the Synopsis.) unspecified-2-1::result_type is + defined as R. +

+

get_pointer

+

template<class T> T * get_pointer(T * p)

+
+

+ Returns: p. +

+

+ Throws: Nothing. +

+
+

mem_fn

+

template<class R, class T> unspecified-1 mem_fn(R + (T::*pmf) ())

+
+

+ Returns: a function object f such that the expression f(t) + is equivalent to (t.*pmf)() when t is an l-value of type T + or derived, (get_pointer(t)->*pmf)() otherwise. +

+

+ Throws: Nothing. +

+
+

template<class R, class T> unspecified-2 mem_fn(R + (T::*pmf) () const)

+
+

+ Returns: a function object f such that the expression f(t) + is equivalent to (t.*pmf)() when t is of type T + [const] or derived, (get_pointer(t)->*pmf)() + otherwise. +

+

+ Throws: Nothing. +

+
+

template<class R, class T> unspecified-2-1 mem_fn(R + T::*pm)

+
+

+ Returns: a function object f such that the expression f(t) + is equivalent to t.*pm when t is of type T [const] + or derived, get_pointer(t)->*pm otherwise. +

+

+ Throws: Nothing. +

+
+

template<class R, class T, class A1> unspecified-3 mem_fn(R + (T::*pmf) (A1))

+
+

+ Returns: a function object f such that the expression f(t, a1) + is equivalent to (t.*pmf)(a1) when t is an l-value of type T + or derived, (get_pointer(t)->*pmf)(a1) otherwise. +

+

+ Throws: Nothing. +

+
+

template<class R, class T, class A1> unspecified-4 mem_fn(R + (T::*pmf) (A1) const)

+
+

+ Returns: a function object f such that the expression f(t, a1) + is equivalent to (t.*pmf)(a1) when t is of type T + [const] or derived, (get_pointer(t)->*pmf)(a1) + otherwise. +

+

+ Throws: Nothing. +

+
+

template<class R, class T, class A1, class A2> unspecified-5 + mem_fn(R (T::*pmf) (A1, A2))

+
+

+ Returns: a function object f such that the expression f(t, a1, a2) + is equivalent to (t.*pmf)(a1, a2) when t is an l-value of type + T or derived, (get_pointer(t)->*pmf)(a1, a2) otherwise. +

+

+ Throws: Nothing. +

+
+

template<class R, class T, class A1, class A2> unspecified-6 + mem_fn(R (T::*pmf) (A1, A2) const)

+
+

+ Returns: a function object f such that the expression f(t, a1, a2) + is equivalent to (t.*pmf)(a1, a2) when t is of type T + [const] or derived, (get_pointer(t)->*pmf)(a1, a2) otherwise. +

+

+ Throws: Nothing. +

+
+

Implementation

+

Files

+ +

Dependencies

+ +

Number of Arguments

+

+ This implementation supports member functions with up to eight arguments. This + is not an inherent limitation of the design, but an implementation detail. +

+

"__stdcall", "__cdecl" and "__fastcall" Support

+

+ Some platforms allow several types of member functions that differ by their calling + convention (the rules by which the function is invoked: how are + arguments passed, how is the return value handled, and who cleans up the stack + - if any.) +

+

+ For example, Windows API functions and COM interface member functions use a + calling convention known as __stdcall. Borland VCL components use __fastcall. + UDK, the component model of OpenOffice.org, uses __cdecl. +

+

+ To use mem_fn with __stdcall member functions, #define the + macro BOOST_MEM_FN_ENABLE_STDCALL before including, directly or + indirectly, <boost/mem_fn.hpp>. +

+

To use mem_fn with __fastcall member functions, #define the + macro BOOST_MEM_FN_ENABLE_FASTCALL before including <boost/mem_fn.hpp>. +

+

To use mem_fn with __cdecl member functions, #define the + macro BOOST_MEM_FN_ENABLE_CDECL before including <boost/mem_fn.hpp>. +

+

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. Not following this rule can lead to obscure errors + when a header includes mem_fn.hpp before the macro has been defined.

+

[Note: this is a non-portable extension. It is not part of the interface.] +

+

+ [Note: Some compilers provide only minimal support for the __stdcall keyword.] +

+

Acknowledgements

+

+ Rene Jager's initial suggestion of using traits classes to make mem_fn adapt + to user-defined smart pointers inspired the get_pointer-based design. +

+

+ Numerous improvements were suggested during the formal review period by Richard + Crossley, Jens Maurer, Ed Brey, and others. Review manager was Darin Adler. +

+

+ Steve Anichini pointed out that COM interfaces use __stdcall. +

+

+ Dave Abrahams modified bind and mem_fn to support void returns on + deficient compilers. +

+

Daniel Boelzle pointed out that UDK uses __cdecl.
+
+
+ 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 LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt.

+ + diff --git a/ref.html b/ref.html index a170578..bde1ae4 100644 --- a/ref.html +++ b/ref.html @@ -7,3 +7,9 @@ Automatic redirection failed, please go to ../../doc/html/ref.html + diff --git a/test/Jamfile b/test/Jamfile index f6dd747..0a66de6 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -2,10 +2,9 @@ # # 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) subproject libs/bind/test ; diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index ed8ec80..b88d49e 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -2,10 +2,9 @@ # # 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 ; From 41d9fbc31719f02fc3304df27287bcb80e743386 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 10 Nov 2006 18:27:05 +0000 Subject: [PATCH 10/62] License update [SVN r35988] --- doc/ref.xml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/doc/ref.xml b/doc/ref.xml index f0376c8..39fede9 100644 --- a/doc/ref.xml +++ b/doc/ref.xml @@ -38,11 +38,9 @@ - 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. + 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. From ce24d4f73592a04c3e7b9587df89668afff1dcfe Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 4 Apr 2007 21:30:32 +0000 Subject: [PATCH 11/62] Fixed to compile [SVN r37357] --- bind_visitor.cpp | 38 ++++---------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/bind_visitor.cpp b/bind_visitor.cpp index 3e79579..1ce7b53 100644 --- a/bind_visitor.cpp +++ b/bind_visitor.cpp @@ -31,32 +31,18 @@ #pragma warning(pop) #endif -// default implementation of visit_each - -namespace boost -{ - template void visit_each(V & v, T const & t, long) - { - v(t, 0); - } -} - -// visitor - -int hash = 0; +// struct visitor { - template void operator()(boost::reference_wrapper const & r, int) const + template void operator()( boost::reference_wrapper const & r ) const { std::cout << "Reference to " << typeid(T).name() << " @ " << &r.get() << " (with value " << r.get() << ")\n"; - hash += r.get(); } - template void operator()(T const &, long) const + template 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(bind(f, ref(x), _1, 42), ref(y)), 0); - - return detect_errors(hash == 12); } From e163aeb563bcf6a90797ee1a128e2219d533ee5e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 7 Jul 2007 17:22:26 +0000 Subject: [PATCH 12/62] Use object placeholders for g++ 4.1+, reported and PCH-tested by Daniel Walker [SVN r38164] --- include/boost/bind/placeholders.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/bind/placeholders.hpp b/include/boost/bind/placeholders.hpp index a8098a7..43baee6 100644 --- a/include/boost/bind/placeholders.hpp +++ b/include/boost/bind/placeholders.hpp @@ -25,7 +25,7 @@ namespace { -#if defined(__BORLANDC__) || defined(__GNUC__) +#if defined(__BORLANDC__) || defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ <= 400) static inline boost::arg<1> _1() { return boost::arg<1>(); } static inline boost::arg<2> _2() { return boost::arg<2>(); } From 79f8680eda2351590007fcbe694fe4c0c8f69549 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 7 Jul 2007 17:41:54 +0000 Subject: [PATCH 13/62] Fix #997 [SVN r38165] --- bind.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bind.html b/bind.html index 83794be..36ea678 100644 --- a/bind.html +++ b/bind.html @@ -341,7 +341,7 @@ void render(image & target) { public: - boost::function<void> onClick; + boost::function<void()> onClick; }; class player From 3c24cbedf6ab97e9a5bf70f5828e05f4691d790c Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Wed, 8 Aug 2007 19:02:26 +0000 Subject: [PATCH 14/62] Remove V1 Jamfiles [SVN r38516] --- test/Jamfile | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 test/Jamfile diff --git a/test/Jamfile b/test/Jamfile deleted file mode 100644 index 0a66de6..0000000 --- a/test/Jamfile +++ /dev/null @@ -1,43 +0,0 @@ -# Boost.Bind Library test Jamfile -# -# Copyright (c) 2003-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) - -subproject libs/bind/test ; - -# bring in rules for testing -import testing ; - -# Make tests run by default. -DEPENDS all : bind ; - -{ - test-suite "bind" - : [ run bind_test.cpp ] - [ run bind_dm_test.cpp ] - [ run bind_eq_test.cpp ] - [ run bind_const_test.cpp ] - [ run bind_cv_test.cpp ] - [ run bind_stateful_test.cpp ] - [ run bind_dm2_test.cpp ] - [ run bind_not_test.cpp ] - [ run bind_rel_test.cpp ] - [ run bind_function_test.cpp ] - [ run bind_lookup_problem_test.cpp ] - [ run 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 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 ] - ; -} From e73f08edeec301782c1b3217ceead7a95ae928e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Sch=C3=B6pflin?= Date: Thu, 3 Jan 2008 10:04:39 +0000 Subject: [PATCH 15/62] Modified spelling of my surname to avoid problems with non-ASCII characters. [SVN r42436] --- test/bind_lookup_problem_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/bind_lookup_problem_test.cpp b/test/bind_lookup_problem_test.cpp index 3ed4178..269b80a 100644 --- a/test/bind_lookup_problem_test.cpp +++ b/test/bind_lookup_problem_test.cpp @@ -1,7 +1,7 @@ // // bind_lookup_problem_test.cpp // -// Copyright (C) Markus Schö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 From f1afd177173329e33b61564b1a2b8f54689f77b1 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 15 Feb 2008 18:40:36 +0000 Subject: [PATCH 16/62] Added support for &&, || [SVN r43269] --- include/boost/bind.hpp | 26 ++++++++++++ test/Jamfile.v2 | 1 + test/bind_and_or_test.cpp | 84 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 test/bind_and_or_test.cpp diff --git a/include/boost/bind.hpp b/include/boost/bind.hpp index e1076e0..dd606ad 100644 --- a/include/boost/bind.hpp +++ b/include/boost/bind.hpp @@ -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::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]); } + template bool operator()( type, logical_and & /*f*/, A & a, int ) + { + return a[ base_type::a1_ ] && a[ base_type::a2_ ]; + } + + template bool operator()( type, logical_and const & /*f*/, A & a, int ) const + { + return a[ base_type::a1_ ] && a[ base_type::a2_ ]; + } + + template bool operator()( type, logical_or & /*f*/, A & a, int ) + { + return a[ base_type::a1_ ] || a[ base_type::a2_ ]; + } + + template bool operator()( type, logical_or const & /*f*/, A & a, int ) const + { + return a[ base_type::a1_ ] || a[ base_type::a2_ ]; + } + template 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) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index b88d49e..b7cecea 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -27,6 +27,7 @@ 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 ] diff --git a/test/bind_and_or_test.cpp b/test/bind_and_or_test.cpp new file mode 100644 index 0000000..337a11e --- /dev/null +++ b/test/bind_and_or_test.cpp @@ -0,0 +1,84 @@ +#include + +#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 + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include + +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(); +} From f58543ac11ea0e7f251437b4374608fd4b701cc3 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 19 Feb 2008 14:51:10 +0000 Subject: [PATCH 17/62] Fix #1641. [SVN r43319] --- bind.html | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/bind.html b/bind.html index 36ea678..8570bd6 100644 --- a/bind.html +++ b/bind.html @@ -188,6 +188,27 @@ bind(std::less<int>(), _1, 9)(x); // x < 9

[Note: the ability to omit the return type is not available on all compilers.]

+

By default, bind makes a copy of the provided function object. + boost::ref and boost::cref 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.

+
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 );
+

Using bind with pointers to members

Pointers to member functions and pointers to data members are not function objects, because they do not support operator(). For convenience, bind @@ -859,7 +880,7 @@ namespace by Jaakko Järvi;

  • The Lambda Library - (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);
  • Extensions to the STL by Petter @@ -890,7 +911,7 @@ namespace

    Copyright © 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 LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.

    From ef993c777a54b2d485c6d1ca4aab9b7131f2a6c0 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 19 Feb 2008 14:59:28 +0000 Subject: [PATCH 18/62] Fix #1646. [SVN r43320] --- bind.html | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bind.html b/bind.html index 8570bd6..f5bcea0 100644 --- a/bind.html +++ b/bind.html @@ -306,13 +306,13 @@ std::for_each(v.begin(), v.end(), bind(apply<void>(), _1, 5)); evaluation, use protect(bind(f, ...)).

    Overloaded operators (new in Boost 1.33)

    For convenience, the function objects produced by bind overload the - logical not operator ! and the relational operators ==, - !=, <, <=, >, - >=.

    + logical not operator ! and the relational and logical operators ==, + !=, <, <=, >, + >=, &&, ||.

    !bind(f, ...) is equivalent to bind( logical_not(), bind(f, ...) ), where logical_not is a function object that takes one argument x and returns !x.

    -

    bind(f, ...) op x, where op is a relational operator, +

    bind(f, ...) op x, where op is a relational or logical operator, is equivalent to bind( relation(), bind(f, ...), x ), where relation is a function object that takes two arguments a and b and returns a op b.

    @@ -320,7 +320,8 @@ std::for_each(v.begin(), v.end(), bind(apply<void>(), _1, 5));

    std::remove_if( first, last, !bind( &X::visible, _1 ) ); // remove invisible objects

    and compare the result of bind against a value:

    -

    std::find_if( first, last, bind( &X::name, _1 ) == "peter" );

    +

    std::find_if( first, last, bind( &X::name, _1 ) == "Peter" );

    +

    std::find_if( first, last, bind( &X::name, _1 ) == "Peter" || bind( &X::name, _1 ) == "Paul" );

    against a placeholder:

    bind( &X::name, _1 ) == _2

    or against another bind expression:

    From aef08dd0cdf5098281c5a1003e7c05a0abeb0843 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 19 Feb 2008 15:09:10 +0000 Subject: [PATCH 19/62] Fix #1642. [SVN r43321] --- bind.html | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/bind.html b/bind.html index f5bcea0..f60cab0 100644 --- a/bind.html +++ b/bind.html @@ -307,21 +307,22 @@ std::for_each(v.begin(), v.end(), bind(apply<void>(), _1, 5));

    Overloaded operators (new in Boost 1.33)

    For convenience, the function objects produced by bind overload the logical not operator ! and the relational and logical operators ==, - !=, <, <=, >, - >=, &&, ||.

    + !=, <, <=, >, >=, + &&, ||.

    !bind(f, ...) is equivalent to bind( logical_not(), bind(f, ...) ), where logical_not is a function object that takes one argument x and returns !x.

    -

    bind(f, ...) op x, where op is a relational or logical operator, - is equivalent to bind( relation(), bind(f, ...), x ), where relation - is a function object that takes two arguments a and b and - returns a op b.

    +

    bind(f, ...) op x, where op is a relational or + logical operator, is equivalent to bind( relation(), bind(f, ...), x ), + where relation is a function object that takes two arguments a + and b and returns a op b.

    What this means in practice is that you can conveniently negate the result of bind:

    std::remove_if( first, last, !bind( &X::visible, _1 ) ); // remove invisible objects

    and compare the result of bind against a value:

    std::find_if( first, last, bind( &X::name, _1 ) == "Peter" );

    -

    std::find_if( first, last, bind( &X::name, _1 ) == "Peter" || bind( &X::name, _1 ) == "Paul" );

    +

    std::find_if( first, last, bind( &X::name, _1 ) == "Peter" || bind( + &X::name, _1 ) == "Paul" );

    against a placeholder:

    bind( &X::name, _1 ) == _2

    or against another bind expression:

    @@ -384,10 +385,12 @@ void connect() }

    Limitations

    -

    The function objects generated by bind 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 - the forwarding problem.

    +

    As a general rule, the function objects generated by bind 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 + the forwarding problem. (It will be fixed in the next standard, usually + called C++0x.)

    The library uses signatures of the form

    template<class T> void f(T & t);
    @@ -395,17 +398,17 @@ void connect()
     		

    to accept arguments of arbitrary types and pass them on unmodified. As noted, this does not work with non-const r-values.

    -

    An oft-proposed "solution" to this problem is to add an overload: +

    On compilers that support partial ordering of function templates, a possible + solution is to add an overload:

    template<class T> void f(T & t);
     template<class T> void f(T const & t);
     
    -

    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. -

    -

    [Note: this is a dark corner of the language, and the - corresponding issue has only recently been resolved.] +

    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.

    Frequently Asked Questions

    Why doesn't this compile?

    From dfd3da2cc461a6c77d80074b6088e9b0eed459a2 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 19 Feb 2008 15:40:58 +0000 Subject: [PATCH 20/62] Fix #1643. [SVN r43323] --- bind.html | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/bind.html b/bind.html index f60cab0..74110c5 100644 --- a/bind.html +++ b/bind.html @@ -60,6 +60,7 @@

    Inappropriate use of bind<R>(f, ...)

    Binding a nonstandard function

    +

    Binding an overloaded function

    const in signatures

    MSVC specific: using boost::bind;

    @@ -553,6 +554,37 @@ int main() recognized by the short form of bind.

    See also "__stdcall" and "pascal" Support.

    +

    Binding an overloaded function

    +

    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:

    +
    struct X
    +{
    +    int& get();
    +    int const& get() const;
    +};
    +
    +int main()
    +{
    +    boost::bind( &X::get, _1 );
    +}
    +
    +

    The ambiguity can be resolved manually by casting the (member) function pointer + to the desired type:

    +
    int main()
    +{
    +    boost::bind( static_cast< int const& (X::*) () const >( &X::get ), _1 );
    +}
    +
    +

    Another, arguably more readable, alternative is to introduce a temporary + variable:

    +
    int main()
    +{
    +    int const& (X::*get) () const = &X::get;
    +    boost::bind( get, _1 );
    +}
    +

    const in signatures

    Some compilers, including MSVC 6.0 and Borland C++ 5.5.1, have problems with the top-level const in function signatures: From 037a4d1976f1f8388b9fc4ac2286c34e8e5a4290 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 21 Apr 2008 21:29:28 +0000 Subject: [PATCH 21/62] Add ref_fn_test.cpp per #1846. [SVN r44704] --- test/Jamfile.v2 | 1 + test/ref_fn_test.cpp | 81 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 test/ref_fn_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index b7cecea..59cf31a 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -34,4 +34,5 @@ test-suite "bind" [ run mem_fn_eq_test.cpp ] [ run mem_fn_dm_test.cpp ] [ run mem_fn_rv_test.cpp ] + [ run ref_fn_test.cpp ] ; diff --git a/test/ref_fn_test.cpp b/test/ref_fn_test.cpp new file mode 100644 index 0000000..aec54e8 --- /dev/null +++ b/test/ref_fn_test.cpp @@ -0,0 +1,81 @@ +#include + +#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 +#include + + +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(); +} From 203ca82ef2f721ecb61a4910d604e77c825dba80 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 21 May 2008 19:49:47 +0000 Subject: [PATCH 22/62] bind( type(), f, ... ) now works when f is a member function. [SVN r45619] --- include/boost/bind.hpp | 4 + include/boost/bind/bind_mf2_cc.hpp | 228 +++++++++++++++++++++++++++++ test/Jamfile.v2 | 3 + test/bind_fn2_test.cpp | 171 ++++++++++++++++++++++ test/bind_fnobj2_test.cpp | 76 ++++++++++ test/bind_mf2_test.cpp | 162 ++++++++++++++++++++ 6 files changed, 644 insertions(+) create mode 100644 include/boost/bind/bind_mf2_cc.hpp create mode 100644 test/bind_fn2_test.cpp create mode 100644 test/bind_fnobj2_test.cpp create mode 100644 test/bind_mf2_test.cpp diff --git a/include/boost/bind.hpp b/include/boost/bind.hpp index dd606ad..07b84d3 100644 --- a/include/boost/bind.hpp +++ b/include/boost/bind.hpp @@ -1568,6 +1568,7 @@ template +#include #undef BOOST_BIND_MF_NAME #undef BOOST_BIND_MF_CC @@ -1578,6 +1579,7 @@ template +#include #undef BOOST_BIND_MF_NAME #undef BOOST_BIND_MF_CC @@ -1590,6 +1592,7 @@ template +#include #undef BOOST_BIND_MF_NAME #undef BOOST_BIND_MF_CC @@ -1602,6 +1605,7 @@ template +#include #undef BOOST_BIND_MF_NAME #undef BOOST_BIND_MF_CC diff --git a/include/boost/bind/bind_mf2_cc.hpp b/include/boost/bind/bind_mf2_cc.hpp new file mode 100644 index 0000000..fdb4495 --- /dev/null +++ b/include/boost/bind/bind_mf2_cc.hpp @@ -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 + _bi::bind_t, typename _bi::list_av_1::type> + BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) (), A1 a1) +{ + typedef _mfi::BOOST_BIND_MF_NAME(mf0) F; + typedef typename _bi::list_av_1::type list_type; + return _bi::bind_t(F(f), list_type(a1)); +} + +template + _bi::bind_t, typename _bi::list_av_1::type> + BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) () const, A1 a1) +{ + typedef _mfi::BOOST_BIND_MF_NAME(cmf0) F; + typedef typename _bi::list_av_1::type list_type; + return _bi::bind_t(F(f), list_type(a1)); +} + +// 1 + +template + _bi::bind_t, typename _bi::list_av_2::type> + BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) (B1), A1 a1, A2 a2) +{ + typedef _mfi::BOOST_BIND_MF_NAME(mf1) F; + typedef typename _bi::list_av_2::type list_type; + return _bi::bind_t(F(f), list_type(a1, a2)); +} + +template + _bi::bind_t, typename _bi::list_av_2::type> + BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) (B1) const, A1 a1, A2 a2) +{ + typedef _mfi::BOOST_BIND_MF_NAME(cmf1) F; + typedef typename _bi::list_av_2::type list_type; + return _bi::bind_t(F(f), list_type(a1, a2)); +} + +// 2 + +template + _bi::bind_t, typename _bi::list_av_3::type> + BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) (B1, B2), A1 a1, A2 a2, A3 a3) +{ + typedef _mfi::BOOST_BIND_MF_NAME(mf2) F; + typedef typename _bi::list_av_3::type list_type; + return _bi::bind_t(F(f), list_type(a1, a2, a3)); +} + +template + _bi::bind_t, typename _bi::list_av_3::type> + BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) (B1, B2) const, A1 a1, A2 a2, A3 a3) +{ + typedef _mfi::BOOST_BIND_MF_NAME(cmf2) F; + typedef typename _bi::list_av_3::type list_type; + return _bi::bind_t(F(f), list_type(a1, a2, a3)); +} + +// 3 + +template + _bi::bind_t, typename _bi::list_av_4::type> + BOOST_BIND(boost::type, 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) F; + typedef typename _bi::list_av_4::type list_type; + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4)); +} + +template + _bi::bind_t, typename _bi::list_av_4::type> + BOOST_BIND(boost::type, 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) F; + typedef typename _bi::list_av_4::type list_type; + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4)); +} + +// 4 + +template + _bi::bind_t, typename _bi::list_av_5::type> + BOOST_BIND(boost::type, 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) F; + typedef typename _bi::list_av_5::type list_type; + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5)); +} + +template + _bi::bind_t, typename _bi::list_av_5::type> + BOOST_BIND(boost::type, 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) F; + typedef typename _bi::list_av_5::type list_type; + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5)); +} + +// 5 + +template + _bi::bind_t, typename _bi::list_av_6::type> + BOOST_BIND(boost::type, 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) F; + typedef typename _bi::list_av_6::type list_type; + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6)); +} + +template + _bi::bind_t, typename _bi::list_av_6::type> + BOOST_BIND(boost::type, 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) F; + typedef typename _bi::list_av_6::type list_type; + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6)); +} + +// 6 + +template + _bi::bind_t, typename _bi::list_av_7::type> + BOOST_BIND(boost::type, 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) F; + typedef typename _bi::list_av_7::type list_type; + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6, a7)); +} + +template + _bi::bind_t, typename _bi::list_av_7::type> + BOOST_BIND(boost::type, 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) F; + typedef typename _bi::list_av_7::type list_type; + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6, a7)); +} + +// 7 + +template + _bi::bind_t, typename _bi::list_av_8::type> + BOOST_BIND(boost::type, 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) F; + typedef typename _bi::list_av_8::type list_type; + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8)); +} + +template + _bi::bind_t, typename _bi::list_av_8::type> + BOOST_BIND(boost::type, 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) F; + typedef typename _bi::list_av_8::type list_type; + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8)); +} + +// 8 + +template + _bi::bind_t, typename _bi::list_av_9::type> + BOOST_BIND(boost::type, 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) F; + typedef typename _bi::list_av_9::type list_type; + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9)); +} + +template + _bi::bind_t, typename _bi::list_av_9::type> + BOOST_BIND(boost::type, 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) F; + typedef typename _bi::list_av_9::type list_type; + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9)); +} diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 59cf31a..38fb264 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -35,4 +35,7 @@ test-suite "bind" [ 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 ] ; diff --git a/test/bind_fn2_test.cpp b/test/bind_fn2_test.cpp new file mode 100644 index 0000000..93f587c --- /dev/null +++ b/test/bind_fn2_test.cpp @@ -0,0 +1,171 @@ +#include + +#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 + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include + +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(), f_0 )(); BOOST_TEST( global_result == 17041L ); + bind( type(), f_1, 1 )(); BOOST_TEST( global_result == 1L ); + bind( type(), f_2, 1, 2 )(); BOOST_TEST( global_result == 21L ); + bind( type(), f_3, 1, 2, 3 )(); BOOST_TEST( global_result == 321L ); + bind( type(), f_4, 1, 2, 3, 4 )(); BOOST_TEST( global_result == 4321L ); + bind( type(), f_5, 1, 2, 3, 4, 5 )(); BOOST_TEST( global_result == 54321L ); + bind( type(), f_6, 1, 2, 3, 4, 5, 6 )(); BOOST_TEST( global_result == 654321L ); + bind( type(), f_7, 1, 2, 3, 4, 5, 6, 7 )(); BOOST_TEST( global_result == 7654321L ); + bind( type(), f_8, 1, 2, 3, 4, 5, 6, 7, 8 )(); BOOST_TEST( global_result == 87654321L ); + bind( type(), f_9, 1, 2, 3, 4, 5, 6, 7, 8, 9 )(); BOOST_TEST( global_result == 987654321L ); + + bind( type(), fv_0 )(); BOOST_TEST( global_result == 17041L ); + bind( type(), fv_1, 1 )(); BOOST_TEST( global_result == 1L ); + bind( type(), fv_2, 1, 2 )(); BOOST_TEST( global_result == 21L ); + bind( type(), fv_3, 1, 2, 3 )(); BOOST_TEST( global_result == 321L ); + bind( type(), fv_4, 1, 2, 3, 4 )(); BOOST_TEST( global_result == 4321L ); + bind( type(), fv_5, 1, 2, 3, 4, 5 )(); BOOST_TEST( global_result == 54321L ); + bind( type(), fv_6, 1, 2, 3, 4, 5, 6 )(); BOOST_TEST( global_result == 654321L ); + bind( type(), fv_7, 1, 2, 3, 4, 5, 6, 7 )(); BOOST_TEST( global_result == 7654321L ); + bind( type(), fv_8, 1, 2, 3, 4, 5, 6, 7, 8 )(); BOOST_TEST( global_result == 87654321L ); + bind( type(), fv_9, 1, 2, 3, 4, 5, 6, 7, 8, 9 )(); BOOST_TEST( global_result == 987654321L ); +} + +int main() +{ + function_test(); + return boost::report_errors(); +} diff --git a/test/bind_fnobj2_test.cpp b/test/bind_fnobj2_test.cpp new file mode 100644 index 0000000..a85fe5d --- /dev/null +++ b/test/bind_fnobj2_test.cpp @@ -0,0 +1,76 @@ +#include + +#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 + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include + +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(), ref(x) )(); + bind( type(), ref(x), 1 )(); + bind( type(), ref(x), 1, 2 )(); + bind( type(), ref(x), 1, 2, 3 )(); + bind( type(), ref(x), 1, 2, 3, 4 )(); + bind( type(), ref(x), 1, 2, 3, 4, 5 )(); + bind( type(), ref(x), 1, 2, 3, 4, 5, 6 )(); + bind( type(), ref(x), 1, 2, 3, 4, 5, 6, 7)(); + bind( type(), ref(x), 1, 2, 3, 4, 5, 6, 7, 8 )(); + bind( type(), 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(); +} diff --git a/test/bind_mf2_test.cpp b/test/bind_mf2_test.cpp new file mode 100644 index 0000000..c04f958 --- /dev/null +++ b/test/bind_mf2_test.cpp @@ -0,0 +1,162 @@ +#include + +#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 + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include + +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(), &X::f0, &x )(); + bind( type(), &X::f0, ref(x) )(); + + bind( type(), &X::g0, &x )(); + bind( type(), &X::g0, x )(); + bind( type(), &X::g0, ref(x) )(); + + // 1 + + bind( type(), &X::f1, &x, 1 )(); + bind( type(), &X::f1, ref(x), 1 )(); + + bind( type(), &X::g1, &x, 1 )(); + bind( type(), &X::g1, x, 1 )(); + bind( type(), &X::g1, ref(x), 1 )(); + + // 2 + + bind( type(), &X::f2, &x, 1, 2 )(); + bind( type(), &X::f2, ref(x), 1, 2 )(); + + bind( type(), &X::g2, &x, 1, 2 )(); + bind( type(), &X::g2, x, 1, 2 )(); + bind( type(), &X::g2, ref(x), 1, 2 )(); + + // 3 + + bind( type(), &X::f3, &x, 1, 2, 3 )(); + bind( type(), &X::f3, ref(x), 1, 2, 3 )(); + + bind( type(), &X::g3, &x, 1, 2, 3 )(); + bind( type(), &X::g3, x, 1, 2, 3 )(); + bind( type(), &X::g3, ref(x), 1, 2, 3 )(); + + // 4 + + bind( type(), &X::f4, &x, 1, 2, 3, 4 )(); + bind( type(), &X::f4, ref(x), 1, 2, 3, 4 )(); + + bind( type(), &X::g4, &x, 1, 2, 3, 4 )(); + bind( type(), &X::g4, x, 1, 2, 3, 4 )(); + bind( type(), &X::g4, ref(x), 1, 2, 3, 4 )(); + + // 5 + + bind( type(), &X::f5, &x, 1, 2, 3, 4, 5 )(); + bind( type(), &X::f5, ref(x), 1, 2, 3, 4, 5 )(); + + bind( type(), &X::g5, &x, 1, 2, 3, 4, 5 )(); + bind( type(), &X::g5, x, 1, 2, 3, 4, 5 )(); + bind( type(), &X::g5, ref(x), 1, 2, 3, 4, 5 )(); + + // 6 + + bind( type(), &X::f6, &x, 1, 2, 3, 4, 5, 6 )(); + bind( type(), &X::f6, ref(x), 1, 2, 3, 4, 5, 6 )(); + + bind( type(), &X::g6, &x, 1, 2, 3, 4, 5, 6 )(); + bind( type(), &X::g6, x, 1, 2, 3, 4, 5, 6 )(); + bind( type(), &X::g6, ref(x), 1, 2, 3, 4, 5, 6 )(); + + // 7 + + bind( type(), &X::f7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind( type(), &X::f7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + bind( type(), &X::g7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind( type(), &X::g7, x, 1, 2, 3, 4, 5, 6, 7)(); + bind( type(), &X::g7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + // 8 + + bind( type(), &X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8 )(); + bind( type(), &X::f8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8 )(); + + bind( type(), &X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8 )(); + bind( type(), &X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8 )(); + bind( type(), &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(); +} From 0dd5dae4e8d607328ded5973526b1b13fd844e59 Mon Sep 17 00:00:00 2001 From: Ronald Garcia Date: Tue, 22 Jul 2008 14:55:05 +0000 Subject: [PATCH 23/62] Added documentation for unwrap_ref. [SVN r47689] --- doc/ref.xml | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/doc/ref.xml b/doc/ref.xml index 39fede9..c64f316 100644 --- a/doc/ref.xml +++ b/doc/ref.xml @@ -59,10 +59,13 @@ references to function templates (algorithms) that would usually take copies of their arguments. It defines the class template boost::reference_wrapper<T>, - the two functions + two functions boost::ref and boost::cref that return - instances of boost::reference_wrapper<T>, and the + instances of boost::reference_wrapper<T>, + a function boost::unwrap_ref + that unwraps a boost::reference_wrapper<T> or + returns a reference to any other type of object, and the two traits classes boost::is_reference_wrapper<T> and @@ -90,6 +93,11 @@ boost::cref(x) returns a boost::reference_wrapper<X const>(x). + The expression boost::unwrap_ref(x) + returns a + boost::unwrap_reference<X>::type& where X + is the type of x. + The expression boost::is_reference_wrapper<T>::value is true if T is a reference_wrapper, and @@ -180,6 +188,19 @@ Does not throw. + + + + unwrap_reference<T>::type& + + T& + + + unwrap_reference<T>::type&(t) + + Does not throw. + + @@ -234,7 +255,8 @@ Peter Dimov because they are generally useful. Douglas Gregor and Dave Abrahams contributed is_reference_wrapper and - unwrap_reference. + unwrap_reference. Frank Mori Hess and Ronald + Garcia contributed boost::unwrap_ref - \ No newline at end of file + From 1b292ee4876d210fdcd06dee8a7623950e4986ba Mon Sep 17 00:00:00 2001 From: Ronald Garcia Date: Tue, 22 Jul 2008 14:58:14 +0000 Subject: [PATCH 24/62] For building the ref docs stand-alone. [SVN r47690] --- doc/Jamfile.v2 | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 doc/Jamfile.v2 diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 new file mode 100644 index 0000000..98582fa --- /dev/null +++ b/doc/Jamfile.v2 @@ -0,0 +1,10 @@ +# Copyright (c) 2002 Douglas Gregor + +# 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 ; + From 48c5a6e682ff9ed38f7f8ee15e90397aa2b734db Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 17 Sep 2008 23:07:33 +0000 Subject: [PATCH 25/62] Fix #2245. [SVN r48840] --- include/boost/bind/bind_mf2_cc.hpp | 144 ++++++++++++++--------------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/include/boost/bind/bind_mf2_cc.hpp b/include/boost/bind/bind_mf2_cc.hpp index fdb4495..66476bc 100644 --- a/include/boost/bind/bind_mf2_cc.hpp +++ b/include/boost/bind/bind_mf2_cc.hpp @@ -15,214 +15,214 @@ // 0 -template - _bi::bind_t, typename _bi::list_av_1::type> - BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) (), A1 a1) + _bi::bind_t, typename _bi::list_av_1::type> + BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) (), A1 a1) { typedef _mfi::BOOST_BIND_MF_NAME(mf0) F; typedef typename _bi::list_av_1::type list_type; - return _bi::bind_t(F(f), list_type(a1)); + return _bi::bind_t(F(f), list_type(a1)); } -template - _bi::bind_t, typename _bi::list_av_1::type> - BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) () const, A1 a1) + _bi::bind_t, typename _bi::list_av_1::type> + BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) () const, A1 a1) { typedef _mfi::BOOST_BIND_MF_NAME(cmf0) F; typedef typename _bi::list_av_1::type list_type; - return _bi::bind_t(F(f), list_type(a1)); + return _bi::bind_t(F(f), list_type(a1)); } // 1 -template - _bi::bind_t, typename _bi::list_av_2::type> - BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) (B1), A1 a1, A2 a2) + _bi::bind_t, typename _bi::list_av_2::type> + BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) (B1), A1 a1, A2 a2) { typedef _mfi::BOOST_BIND_MF_NAME(mf1) F; typedef typename _bi::list_av_2::type list_type; - return _bi::bind_t(F(f), list_type(a1, a2)); + return _bi::bind_t(F(f), list_type(a1, a2)); } -template - _bi::bind_t, typename _bi::list_av_2::type> - BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) (B1) const, A1 a1, A2 a2) + _bi::bind_t, typename _bi::list_av_2::type> + BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) (B1) const, A1 a1, A2 a2) { typedef _mfi::BOOST_BIND_MF_NAME(cmf1) F; typedef typename _bi::list_av_2::type list_type; - return _bi::bind_t(F(f), list_type(a1, a2)); + return _bi::bind_t(F(f), list_type(a1, a2)); } // 2 -template - _bi::bind_t, typename _bi::list_av_3::type> - BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) (B1, B2), A1 a1, A2 a2, A3 a3) + _bi::bind_t, typename _bi::list_av_3::type> + BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) (B1, B2), A1 a1, A2 a2, A3 a3) { typedef _mfi::BOOST_BIND_MF_NAME(mf2) F; typedef typename _bi::list_av_3::type list_type; - return _bi::bind_t(F(f), list_type(a1, a2, a3)); + return _bi::bind_t(F(f), list_type(a1, a2, a3)); } -template - _bi::bind_t, typename _bi::list_av_3::type> - BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) (B1, B2) const, A1 a1, A2 a2, A3 a3) + _bi::bind_t, typename _bi::list_av_3::type> + BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) (B1, B2) const, A1 a1, A2 a2, A3 a3) { typedef _mfi::BOOST_BIND_MF_NAME(cmf2) F; typedef typename _bi::list_av_3::type list_type; - return _bi::bind_t(F(f), list_type(a1, a2, a3)); + return _bi::bind_t(F(f), list_type(a1, a2, a3)); } // 3 -template - _bi::bind_t, typename _bi::list_av_4::type> - BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3), A1 a1, A2 a2, A3 a3, A4 a4) + _bi::bind_t, typename _bi::list_av_4::type> + BOOST_BIND(boost::type, 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) F; typedef typename _bi::list_av_4::type list_type; - return _bi::bind_t(F(f), list_type(a1, a2, a3, a4)); + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4)); } -template - _bi::bind_t, typename _bi::list_av_4::type> - BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3) const, A1 a1, A2 a2, A3 a3, A4 a4) + _bi::bind_t, typename _bi::list_av_4::type> + BOOST_BIND(boost::type, 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) F; typedef typename _bi::list_av_4::type list_type; - return _bi::bind_t(F(f), list_type(a1, a2, a3, a4)); + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4)); } // 4 -template - _bi::bind_t, typename _bi::list_av_5::type> - BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) + _bi::bind_t, typename _bi::list_av_5::type> + BOOST_BIND(boost::type, 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) F; typedef typename _bi::list_av_5::type list_type; - return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5)); + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5)); } -template - _bi::bind_t, typename _bi::list_av_5::type> - BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4) const, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) + _bi::bind_t, typename _bi::list_av_5::type> + BOOST_BIND(boost::type, 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) F; typedef typename _bi::list_av_5::type list_type; - return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5)); + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5)); } // 5 -template - _bi::bind_t, typename _bi::list_av_6::type> - BOOST_BIND(boost::type, R (BOOST_BIND_MF_CC T::*f) (B1, B2, B3, B4, B5), A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) + _bi::bind_t, typename _bi::list_av_6::type> + BOOST_BIND(boost::type, 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) F; typedef typename _bi::list_av_6::type list_type; - return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6)); + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6)); } -template - _bi::bind_t, typename _bi::list_av_6::type> - BOOST_BIND(boost::type, 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) + _bi::bind_t, typename _bi::list_av_6::type> + BOOST_BIND(boost::type, 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) F; typedef typename _bi::list_av_6::type list_type; - return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6)); + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6)); } // 6 -template - _bi::bind_t, typename _bi::list_av_7::type> - BOOST_BIND(boost::type, 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) + _bi::bind_t, typename _bi::list_av_7::type> + BOOST_BIND(boost::type, 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) F; typedef typename _bi::list_av_7::type list_type; - return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6, a7)); + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6, a7)); } -template - _bi::bind_t, typename _bi::list_av_7::type> - BOOST_BIND(boost::type, 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) + _bi::bind_t, typename _bi::list_av_7::type> + BOOST_BIND(boost::type, 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) F; typedef typename _bi::list_av_7::type list_type; - return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6, a7)); + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6, a7)); } // 7 -template - _bi::bind_t, typename _bi::list_av_8::type> - BOOST_BIND(boost::type, 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) + _bi::bind_t, typename _bi::list_av_8::type> + BOOST_BIND(boost::type, 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) F; typedef typename _bi::list_av_8::type list_type; - return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8)); + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8)); } -template - _bi::bind_t, typename _bi::list_av_8::type> - BOOST_BIND(boost::type, 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) + _bi::bind_t, typename _bi::list_av_8::type> + BOOST_BIND(boost::type, 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) F; typedef typename _bi::list_av_8::type list_type; - return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8)); + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8)); } // 8 -template - _bi::bind_t, typename _bi::list_av_9::type> - BOOST_BIND(boost::type, 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) + _bi::bind_t, typename _bi::list_av_9::type> + BOOST_BIND(boost::type, 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) F; typedef typename _bi::list_av_9::type list_type; - return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9)); + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9)); } -template - _bi::bind_t, typename _bi::list_av_9::type> - BOOST_BIND(boost::type, 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) + _bi::bind_t, typename _bi::list_av_9::type> + BOOST_BIND(boost::type, 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) F; typedef typename _bi::list_av_9::type list_type; - return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9)); + return _bi::bind_t(F(f), list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9)); } From 61519fcae29b2ea9e86732aed4f7adf7fb735a25 Mon Sep 17 00:00:00 2001 From: "Michael A. Jackson" Date: Sat, 1 Nov 2008 13:15:41 +0000 Subject: [PATCH 26/62] Continuing merge of CMake build system files into trunk with the encouragement of Doug Gregor [SVN r49510] --- CMakeLists.txt | 22 ++++++++++++++++++++++ test/CMakeLists.txt | 28 ++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..f654c67 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,22 @@ +#---------------------------------------------------------------------------- +# This file was automatically generated from the original CMakeLists.txt file +# Add a variable to hold the headers for the library +set (lib_headers + bind.hpp + bind +) + +# Add a library target to the build system +boost_library_project( + bind + # SRCDIRS + TESTDIRS test + HEADERS ${lib_headers} + # DOCDIRS + DESCRIPTION "A generalization of the standard functions std::bind1st and std::bind2nd. It supports arbitrary function objects, functions, function pointers, and member function pointers, and is able to bind any argument to a specific value or route input arguments into arbitrary positions." + MODULARIZED + AUTHORS "Peter Dimov " + # MAINTAINERS +) + + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..7fe00fa --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,28 @@ +SET(tests + bind_test + bind_dm_test + bind_eq_test + bind_const_test + bind_cv_test + bind_stateful_test + bind_dm2_test + bind_not_test + bind_rel_test + bind_function_test + bind_lookup_problem_test + bind_rv_sp_test + bind_dm3_test + bind_visit_test + mem_fn_test + mem_fn_void_test + mem_fn_derived_test + mem_fn_eq_test + mem_fn_dm_test + mem_fn_rv_test + ) +FOREACH(test ${tests}) + boost_test_run(${test}) +ENDFOREACH(test ${tests}) + +boost_test_compile(bind_unary_addr) + From 0b72bfbd9ba52a48a363c8be7aca43b1266a7b46 Mon Sep 17 00:00:00 2001 From: "Michael A. Jackson" Date: Fri, 7 Nov 2008 17:02:56 +0000 Subject: [PATCH 27/62] Updating CMake files to latest trunk. Added dependency information for regression tests and a few new macros for internal use. [SVN r49627] --- test/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7fe00fa..7dd5a71 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,3 +1,5 @@ +boost_additional_test_dependencies(bind BOOST_DEPENDS test) + SET(tests bind_test bind_dm_test From f09a7a57478f7fe4326df9869a920cb43682889b Mon Sep 17 00:00:00 2001 From: "Michael A. Jackson" Date: Fri, 7 Nov 2008 17:05:27 +0000 Subject: [PATCH 28/62] Updating dependency information for modularized libraries. [SVN r49628] --- module.cmake | 1 + 1 file changed, 1 insertion(+) create mode 100644 module.cmake diff --git a/module.cmake b/module.cmake new file mode 100644 index 0000000..beb4837 --- /dev/null +++ b/module.cmake @@ -0,0 +1 @@ +boost_module(bind DEPENDS utility mpl detail config) \ No newline at end of file From 1d79533df7bd4027c2f086ab6f11c91ed5392533 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Tue, 17 Feb 2009 10:05:58 +0000 Subject: [PATCH 29/62] Add PDF generation options to fix external links to point to the web site. Added a few more Boostbook based libs that were missed first time around. Fixed PDF naming issues. [SVN r51284] --- doc/Jamfile.v2 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index 98582fa..f59b823 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -6,5 +6,8 @@ project boost/doc ; import boostbook : boostbook ; -boostbook ref-doc : ref.xml ; +boostbook ref-doc : ref.xml + : + pdf:boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html + ; From 851903fcc466fc8584e28d87c9935d0e8cb339bc Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 28 Feb 2009 21:26:59 +0000 Subject: [PATCH 30/62] Copy bind.hpp into bind/ [SVN r51487] --- include/boost/bind/bind.hpp | 1719 +++++++++++++++++++++++++++++++++++ 1 file changed, 1719 insertions(+) create mode 100644 include/boost/bind/bind.hpp diff --git a/include/boost/bind/bind.hpp b/include/boost/bind/bind.hpp new file mode 100644 index 0000000..07b84d3 --- /dev/null +++ b/include/boost/bind/bind.hpp @@ -0,0 +1,1719 @@ +#ifndef BOOST_BIND_HPP_INCLUDED +#define BOOST_BIND_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// bind.hpp - binds function objects to arguments +// +// Copyright (c) 2001-2004 Peter Dimov and Multi Media Ltd. +// Copyright (c) 2001 David Abrahams +// 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) +// +// See http://www.boost.org/libs/bind/bind.html for documentation. +// + +#include +#include +#include +#include +#include +#include +#include +#include + +// Borland-specific bug, visit_each() silently fails to produce code + +#if defined(__BORLANDC__) +# define BOOST_BIND_VISIT_EACH boost::visit_each +#else +# define BOOST_BIND_VISIT_EACH visit_each +#endif + +#include + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable: 4512) // assignment operator could not be generated +#endif + +namespace boost +{ + +namespace _bi // implementation details +{ + +// result_traits + +template struct result_traits +{ + typedef R type; +}; + +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) + +struct unspecified {}; + +template struct result_traits +{ + typedef typename F::result_type type; +}; + +template struct result_traits< unspecified, reference_wrapper > +{ + typedef typename F::result_type type; +}; + +#endif + +// ref_compare + +template bool ref_compare( T const & a, T const & b, long ) +{ + return a == b; +} + +template bool ref_compare( arg const &, arg const &, int ) +{ + return true; +} + +template bool ref_compare( arg (*) (), arg (*) (), int ) +{ + return true; +} + +template bool ref_compare( reference_wrapper const & a, reference_wrapper const & b, int ) +{ + return a.get_pointer() == b.get_pointer(); +} + +// bind_t forward declaration for listN + +template class bind_t; + +// value + +template class value +{ +public: + + value(T const & t): t_(t) {} + + T & get() { return t_; } + T const & get() const { return t_; } + + bool operator==(value const & rhs) const + { + return t_ == rhs.t_; + } + +private: + + T t_; +}; + +// type + +template class type {}; + +// unwrap + +template struct unwrapper +{ + static inline F & unwrap( F & f, long ) + { + return f; + } + + template static inline F2 & unwrap( reference_wrapper rf, int ) + { + return rf.get(); + } + + template static inline _mfi::dm unwrap( R T::* pm, int ) + { + return _mfi::dm( pm ); + } +}; + +// listN + +class list0 +{ +public: + + list0() {} + + template T & operator[] (_bi::value & v) const { return v.get(); } + + template T const & operator[] (_bi::value const & v) const { return v.get(); } + + template T & operator[] (reference_wrapper const & v) const { return v.get(); } + + template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } + + template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } + + template R operator()(type, F & f, A &, long) + { + return unwrapper::unwrap(f, 0)(); + } + + template R operator()(type, F const & f, A &, long) const + { + return unwrapper::unwrap(f, 0)(); + } + + template void operator()(type, F & f, A &, int) + { + unwrapper::unwrap(f, 0)(); + } + + template void operator()(type, F const & f, A &, int) const + { + unwrapper::unwrap(f, 0)(); + } + + template void accept(V &) const + { + } + + bool operator==(list0 const &) const + { + return true; + } +}; + +template< class A1 > class list1: private storage1< A1 > +{ +private: + + typedef storage1< A1 > base_type; + +public: + + explicit list1( A1 a1 ): base_type( a1 ) {} + + A1 operator[] (boost::arg<1>) const { return base_type::a1_; } + + A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; } + + template T & operator[] ( _bi::value & v ) const { return v.get(); } + + template T const & operator[] ( _bi::value const & v ) const { return v.get(); } + + template T & operator[] (reference_wrapper const & v) const { return v.get(); } + + template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } + + template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } + + template R operator()(type, F & f, A & a, long) + { + return unwrapper::unwrap(f, 0)(a[base_type::a1_]); + } + + template R operator()(type, F const & f, A & a, long) const + { + return unwrapper::unwrap(f, 0)(a[base_type::a1_]); + } + + template void operator()(type, F & f, A & a, int) + { + unwrapper::unwrap(f, 0)(a[base_type::a1_]); + } + + template void operator()(type, F const & f, A & a, int) const + { + unwrapper::unwrap(f, 0)(a[base_type::a1_]); + } + + template void accept(V & v) const + { + base_type::accept(v); + } + + bool operator==(list1 const & rhs) const + { + return ref_compare(base_type::a1_, rhs.a1_, 0); + } +}; + +struct logical_and; +struct logical_or; + +template< class A1, class A2 > class list2: private storage2< A1, A2 > +{ +private: + + typedef storage2< A1, A2 > base_type; + +public: + + list2( A1 a1, A2 a2 ): base_type( a1, a2 ) {} + + A1 operator[] (boost::arg<1>) const { return base_type::a1_; } + A2 operator[] (boost::arg<2>) const { return base_type::a2_; } + + A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; } + A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; } + + template T & operator[] (_bi::value & v) const { return v.get(); } + + template T const & operator[] (_bi::value const & v) const { return v.get(); } + + template T & operator[] (reference_wrapper const & v) const { return v.get(); } + + template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } + + template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } + + template R operator()(type, F & f, A & a, long) + { + return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]); + } + + template R operator()(type, F const & f, A & a, long) const + { + return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]); + } + + template void operator()(type, F & f, A & a, int) + { + unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]); + } + + template void operator()(type, F const & f, A & a, int) const + { + unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]); + } + + template bool operator()( type, logical_and & /*f*/, A & a, int ) + { + return a[ base_type::a1_ ] && a[ base_type::a2_ ]; + } + + template bool operator()( type, logical_and const & /*f*/, A & a, int ) const + { + return a[ base_type::a1_ ] && a[ base_type::a2_ ]; + } + + template bool operator()( type, logical_or & /*f*/, A & a, int ) + { + return a[ base_type::a1_ ] || a[ base_type::a2_ ]; + } + + template bool operator()( type, logical_or const & /*f*/, A & a, int ) const + { + return a[ base_type::a1_ ] || a[ base_type::a2_ ]; + } + + template void accept(V & v) const + { + base_type::accept(v); + } + + bool operator==(list2 const & rhs) const + { + return ref_compare(base_type::a1_, rhs.a1_, 0) && ref_compare(base_type::a2_, rhs.a2_, 0); + } +}; + +template< class A1, class A2, class A3 > class list3: private storage3< A1, A2, A3 > +{ +private: + + typedef storage3< A1, A2, A3 > base_type; + +public: + + list3( A1 a1, A2 a2, A3 a3 ): base_type( a1, a2, a3 ) {} + + A1 operator[] (boost::arg<1>) const { return base_type::a1_; } + A2 operator[] (boost::arg<2>) const { return base_type::a2_; } + A3 operator[] (boost::arg<3>) const { return base_type::a3_; } + + A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; } + A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; } + A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; } + + template T & operator[] (_bi::value & v) const { return v.get(); } + + template T const & operator[] (_bi::value const & v) const { return v.get(); } + + template T & operator[] (reference_wrapper const & v) const { return v.get(); } + + template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } + + template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } + + template R operator()(type, F & f, A & a, long) + { + return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]); + } + + template R operator()(type, F const & f, A & a, long) const + { + return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]); + } + + template void operator()(type, F & f, A & a, int) + { + unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]); + } + + template void operator()(type, F const & f, A & a, int) const + { + unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]); + } + + template void accept(V & v) const + { + base_type::accept(v); + } + + bool operator==(list3 const & rhs) const + { + return + + ref_compare( base_type::a1_, rhs.a1_, 0 ) && + ref_compare( base_type::a2_, rhs.a2_, 0 ) && + ref_compare( base_type::a3_, rhs.a3_, 0 ); + } +}; + +template< class A1, class A2, class A3, class A4 > class list4: private storage4< A1, A2, A3, A4 > +{ +private: + + typedef storage4< A1, A2, A3, A4 > base_type; + +public: + + list4( A1 a1, A2 a2, A3 a3, A4 a4 ): base_type( a1, a2, a3, a4 ) {} + + A1 operator[] (boost::arg<1>) const { return base_type::a1_; } + A2 operator[] (boost::arg<2>) const { return base_type::a2_; } + A3 operator[] (boost::arg<3>) const { return base_type::a3_; } + A4 operator[] (boost::arg<4>) const { return base_type::a4_; } + + A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; } + A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; } + A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; } + A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; } + + template T & operator[] (_bi::value & v) const { return v.get(); } + + template T const & operator[] (_bi::value const & v) const { return v.get(); } + + template T & operator[] (reference_wrapper const & v) const { return v.get(); } + + template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } + + template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } + + template R operator()(type, F & f, A & a, long) + { + return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_]); + } + + template R operator()(type, F const & f, A & a, long) const + { + return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_]); + } + + template void operator()(type, F & f, A & a, int) + { + unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_]); + } + + template void operator()(type, F const & f, A & a, int) const + { + unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_]); + } + + template void accept(V & v) const + { + base_type::accept(v); + } + + bool operator==(list4 const & rhs) const + { + return + + ref_compare( base_type::a1_, rhs.a1_, 0 ) && + ref_compare( base_type::a2_, rhs.a2_, 0 ) && + ref_compare( base_type::a3_, rhs.a3_, 0 ) && + ref_compare( base_type::a4_, rhs.a4_, 0 ); + } +}; + +template< class A1, class A2, class A3, class A4, class A5 > class list5: private storage5< A1, A2, A3, A4, A5 > +{ +private: + + typedef storage5< A1, A2, A3, A4, A5 > base_type; + +public: + + list5( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5 ): base_type( a1, a2, a3, a4, a5 ) {} + + A1 operator[] (boost::arg<1>) const { return base_type::a1_; } + A2 operator[] (boost::arg<2>) const { return base_type::a2_; } + A3 operator[] (boost::arg<3>) const { return base_type::a3_; } + A4 operator[] (boost::arg<4>) const { return base_type::a4_; } + A5 operator[] (boost::arg<5>) const { return base_type::a5_; } + + A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; } + A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; } + A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; } + A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; } + A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; } + + template T & operator[] (_bi::value & v) const { return v.get(); } + + template T const & operator[] (_bi::value const & v) const { return v.get(); } + + template T & operator[] (reference_wrapper const & v) const { return v.get(); } + + template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } + + template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } + + template R operator()(type, F & f, A & a, long) + { + return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_]); + } + + template R operator()(type, F const & f, A & a, long) const + { + return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_]); + } + + template void operator()(type, F & f, A & a, int) + { + unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_]); + } + + template void operator()(type, F const & f, A & a, int) const + { + unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_]); + } + + template void accept(V & v) const + { + base_type::accept(v); + } + + bool operator==(list5 const & rhs) const + { + return + + ref_compare( base_type::a1_, rhs.a1_, 0 ) && + ref_compare( base_type::a2_, rhs.a2_, 0 ) && + ref_compare( base_type::a3_, rhs.a3_, 0 ) && + ref_compare( base_type::a4_, rhs.a4_, 0 ) && + ref_compare( base_type::a5_, rhs.a5_, 0 ); + } +}; + +template class list6: private storage6< A1, A2, A3, A4, A5, A6 > +{ +private: + + typedef storage6< A1, A2, A3, A4, A5, A6 > base_type; + +public: + + list6( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6 ): base_type( a1, a2, a3, a4, a5, a6 ) {} + + A1 operator[] (boost::arg<1>) const { return base_type::a1_; } + A2 operator[] (boost::arg<2>) const { return base_type::a2_; } + A3 operator[] (boost::arg<3>) const { return base_type::a3_; } + A4 operator[] (boost::arg<4>) const { return base_type::a4_; } + A5 operator[] (boost::arg<5>) const { return base_type::a5_; } + A6 operator[] (boost::arg<6>) const { return base_type::a6_; } + + A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; } + A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; } + A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; } + A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; } + A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; } + A6 operator[] (boost::arg<6> (*) ()) const { return base_type::a6_; } + + template T & operator[] (_bi::value & v) const { return v.get(); } + + template T const & operator[] (_bi::value const & v) const { return v.get(); } + + template T & operator[] (reference_wrapper const & v) const { return v.get(); } + + template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } + + template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } + + template R operator()(type, F & f, A & a, long) + { + return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_]); + } + + template R operator()(type, F const & f, A & a, long) const + { + return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_]); + } + + template void operator()(type, F & f, A & a, int) + { + unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_]); + } + + template void operator()(type, F const & f, A & a, int) const + { + unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_]); + } + + template void accept(V & v) const + { + base_type::accept(v); + } + + bool operator==(list6 const & rhs) const + { + return + + ref_compare( base_type::a1_, rhs.a1_, 0 ) && + ref_compare( base_type::a2_, rhs.a2_, 0 ) && + ref_compare( base_type::a3_, rhs.a3_, 0 ) && + ref_compare( base_type::a4_, rhs.a4_, 0 ) && + ref_compare( base_type::a5_, rhs.a5_, 0 ) && + ref_compare( base_type::a6_, rhs.a6_, 0 ); + } +}; + +template class list7: private storage7< A1, A2, A3, A4, A5, A6, A7 > +{ +private: + + typedef storage7< A1, A2, A3, A4, A5, A6, A7 > base_type; + +public: + + list7( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7 ): base_type( a1, a2, a3, a4, a5, a6, a7 ) {} + + A1 operator[] (boost::arg<1>) const { return base_type::a1_; } + A2 operator[] (boost::arg<2>) const { return base_type::a2_; } + A3 operator[] (boost::arg<3>) const { return base_type::a3_; } + A4 operator[] (boost::arg<4>) const { return base_type::a4_; } + A5 operator[] (boost::arg<5>) const { return base_type::a5_; } + A6 operator[] (boost::arg<6>) const { return base_type::a6_; } + A7 operator[] (boost::arg<7>) const { return base_type::a7_; } + + A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; } + A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; } + A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; } + A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; } + A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; } + A6 operator[] (boost::arg<6> (*) ()) const { return base_type::a6_; } + A7 operator[] (boost::arg<7> (*) ()) const { return base_type::a7_; } + + template T & operator[] (_bi::value & v) const { return v.get(); } + + template T const & operator[] (_bi::value const & v) const { return v.get(); } + + template T & operator[] (reference_wrapper const & v) const { return v.get(); } + + template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } + + template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } + + template R operator()(type, F & f, A & a, long) + { + return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_]); + } + + template R operator()(type, F const & f, A & a, long) const + { + return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_]); + } + + template void operator()(type, F & f, A & a, int) + { + unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_]); + } + + template void operator()(type, F const & f, A & a, int) const + { + unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_]); + } + + template void accept(V & v) const + { + base_type::accept(v); + } + + bool operator==(list7 const & rhs) const + { + return + + ref_compare( base_type::a1_, rhs.a1_, 0 ) && + ref_compare( base_type::a2_, rhs.a2_, 0 ) && + ref_compare( base_type::a3_, rhs.a3_, 0 ) && + ref_compare( base_type::a4_, rhs.a4_, 0 ) && + ref_compare( base_type::a5_, rhs.a5_, 0 ) && + ref_compare( base_type::a6_, rhs.a6_, 0 ) && + ref_compare( base_type::a7_, rhs.a7_, 0 ); + } +}; + +template< class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > class list8: private storage8< A1, A2, A3, A4, A5, A6, A7, A8 > +{ +private: + + typedef storage8< A1, A2, A3, A4, A5, A6, A7, A8 > base_type; + +public: + + list8( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8 ): base_type( a1, a2, a3, a4, a5, a6, a7, a8 ) {} + + A1 operator[] (boost::arg<1>) const { return base_type::a1_; } + A2 operator[] (boost::arg<2>) const { return base_type::a2_; } + A3 operator[] (boost::arg<3>) const { return base_type::a3_; } + A4 operator[] (boost::arg<4>) const { return base_type::a4_; } + A5 operator[] (boost::arg<5>) const { return base_type::a5_; } + A6 operator[] (boost::arg<6>) const { return base_type::a6_; } + A7 operator[] (boost::arg<7>) const { return base_type::a7_; } + A8 operator[] (boost::arg<8>) const { return base_type::a8_; } + + A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; } + A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; } + A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; } + A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; } + A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; } + A6 operator[] (boost::arg<6> (*) ()) const { return base_type::a6_; } + A7 operator[] (boost::arg<7> (*) ()) const { return base_type::a7_; } + A8 operator[] (boost::arg<8> (*) ()) const { return base_type::a8_; } + + template T & operator[] (_bi::value & v) const { return v.get(); } + + template T const & operator[] (_bi::value const & v) const { return v.get(); } + + template T & operator[] (reference_wrapper const & v) const { return v.get(); } + + template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } + + template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } + + template R operator()(type, F & f, A & a, long) + { + return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_]); + } + + template R operator()(type, F const & f, A & a, long) const + { + return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_]); + } + + template void operator()(type, F & f, A & a, int) + { + unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_]); + } + + template void operator()(type, F const & f, A & a, int) const + { + unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_]); + } + + template void accept(V & v) const + { + base_type::accept(v); + } + + bool operator==(list8 const & rhs) const + { + return + + ref_compare( base_type::a1_, rhs.a1_, 0 ) && + ref_compare( base_type::a2_, rhs.a2_, 0 ) && + ref_compare( base_type::a3_, rhs.a3_, 0 ) && + ref_compare( base_type::a4_, rhs.a4_, 0 ) && + ref_compare( base_type::a5_, rhs.a5_, 0 ) && + ref_compare( base_type::a6_, rhs.a6_, 0 ) && + ref_compare( base_type::a7_, rhs.a7_, 0 ) && + ref_compare( base_type::a8_, rhs.a8_, 0 ); + } +}; + +template class list9: private storage9< A1, A2, A3, A4, A5, A6, A7, A8, A9 > +{ +private: + + typedef storage9< A1, A2, A3, A4, A5, A6, A7, A8, A9 > base_type; + +public: + + list9( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9 ): base_type( a1, a2, a3, a4, a5, a6, a7, a8, a9 ) {} + + A1 operator[] (boost::arg<1>) const { return base_type::a1_; } + A2 operator[] (boost::arg<2>) const { return base_type::a2_; } + A3 operator[] (boost::arg<3>) const { return base_type::a3_; } + A4 operator[] (boost::arg<4>) const { return base_type::a4_; } + A5 operator[] (boost::arg<5>) const { return base_type::a5_; } + A6 operator[] (boost::arg<6>) const { return base_type::a6_; } + A7 operator[] (boost::arg<7>) const { return base_type::a7_; } + A8 operator[] (boost::arg<8>) const { return base_type::a8_; } + A9 operator[] (boost::arg<9>) const { return base_type::a9_; } + + A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; } + A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; } + A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; } + A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; } + A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; } + A6 operator[] (boost::arg<6> (*) ()) const { return base_type::a6_; } + A7 operator[] (boost::arg<7> (*) ()) const { return base_type::a7_; } + A8 operator[] (boost::arg<8> (*) ()) const { return base_type::a8_; } + A9 operator[] (boost::arg<9> (*) ()) const { return base_type::a9_; } + + template T & operator[] (_bi::value & v) const { return v.get(); } + + template T const & operator[] (_bi::value const & v) const { return v.get(); } + + template T & operator[] (reference_wrapper const & v) const { return v.get(); } + + template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } + + template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } + + template R operator()(type, F & f, A & a, long) + { + return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_], a[base_type::a9_]); + } + + template R operator()(type, F const & f, A & a, long) const + { + return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_], a[base_type::a9_]); + } + + template void operator()(type, F & f, A & a, int) + { + unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_], a[base_type::a9_]); + } + + template void operator()(type, F const & f, A & a, int) const + { + unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_], a[base_type::a9_]); + } + + template void accept(V & v) const + { + base_type::accept(v); + } + + bool operator==(list9 const & rhs) const + { + return + + ref_compare( base_type::a1_, rhs.a1_, 0 ) && + ref_compare( base_type::a2_, rhs.a2_, 0 ) && + ref_compare( base_type::a3_, rhs.a3_, 0 ) && + ref_compare( base_type::a4_, rhs.a4_, 0 ) && + ref_compare( base_type::a5_, rhs.a5_, 0 ) && + ref_compare( base_type::a6_, rhs.a6_, 0 ) && + ref_compare( base_type::a7_, rhs.a7_, 0 ) && + ref_compare( base_type::a8_, rhs.a8_, 0 ) && + ref_compare( base_type::a9_, rhs.a9_, 0 ); + } +}; + +// bind_t + +#ifndef BOOST_NO_VOID_RETURNS + +template class bind_t +{ +public: + + typedef bind_t this_type; + + bind_t(F f, L const & l): f_(f), l_(l) {} + +#define BOOST_BIND_RETURN return +#include +#undef BOOST_BIND_RETURN + +}; + +#else + +template struct bind_t_generator +{ + +template class implementation +{ +public: + + typedef implementation this_type; + + implementation(F f, L const & l): f_(f), l_(l) {} + +#define BOOST_BIND_RETURN return +#include +#undef BOOST_BIND_RETURN + +}; + +}; + +template<> struct bind_t_generator +{ + +template class implementation +{ +private: + + typedef void R; + +public: + + typedef implementation this_type; + + implementation(F f, L const & l): f_(f), l_(l) {} + +#define BOOST_BIND_RETURN +#include +#undef BOOST_BIND_RETURN + +}; + +}; + +template class bind_t: public bind_t_generator::BOOST_NESTED_TEMPLATE implementation +{ +public: + + bind_t(F f, L const & l): bind_t_generator::BOOST_NESTED_TEMPLATE implementation(f, l) {} + +}; + +#endif + +// function_equal + +#ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP + +// put overloads in _bi, rely on ADL + +# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + +template bool function_equal( bind_t const & a, bind_t const & b ) +{ + return a.compare(b); +} + +# else + +template bool function_equal_impl( bind_t const & a, bind_t const & b, int ) +{ + return a.compare(b); +} + +# endif // #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + +#else // BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP + +// put overloads in boost + +} // namespace _bi + +# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + +template bool function_equal( _bi::bind_t const & a, _bi::bind_t const & b ) +{ + return a.compare(b); +} + +# else + +template bool function_equal_impl( _bi::bind_t const & a, _bi::bind_t const & b, int ) +{ + return a.compare(b); +} + +# endif // #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + +namespace _bi +{ + +#endif // BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP + +// add_value + +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || (__SUNPRO_CC >= 0x530) + +#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x582) ) + +template struct add_value +{ + typedef _bi::value type; +}; + +#else + +template< class T, int I > struct add_value_2 +{ + typedef boost::arg type; +}; + +template< class T > struct add_value_2< T, 0 > +{ + typedef _bi::value< T > type; +}; + +template struct add_value +{ + typedef typename add_value_2< T, boost::is_placeholder< T >::value >::type type; +}; + +#endif + +template struct add_value< value > +{ + typedef _bi::value type; +}; + +template struct add_value< reference_wrapper > +{ + typedef reference_wrapper type; +}; + +template struct add_value< arg > +{ + typedef boost::arg type; +}; + +template struct add_value< arg (*) () > +{ + typedef boost::arg (*type) (); +}; + +template struct add_value< bind_t > +{ + typedef bind_t type; +}; + +#else + +template struct _avt_0; + +template<> struct _avt_0<1> +{ + template struct inner + { + typedef T type; + }; +}; + +template<> struct _avt_0<2> +{ + template struct inner + { + typedef value type; + }; +}; + +typedef char (&_avt_r1) [1]; +typedef char (&_avt_r2) [2]; + +template _avt_r1 _avt_f(value); +template _avt_r1 _avt_f(reference_wrapper); +template _avt_r1 _avt_f(arg); +template _avt_r1 _avt_f(arg (*) ()); +template _avt_r1 _avt_f(bind_t); + +_avt_r2 _avt_f(...); + +template struct add_value +{ + static T t(); + typedef typename _avt_0::template inner::type type; +}; + +#endif + +// list_av_N + +template struct list_av_1 +{ + typedef typename add_value::type B1; + typedef list1 type; +}; + +template struct list_av_2 +{ + typedef typename add_value::type B1; + typedef typename add_value::type B2; + typedef list2 type; +}; + +template struct list_av_3 +{ + typedef typename add_value::type B1; + typedef typename add_value::type B2; + typedef typename add_value::type B3; + typedef list3 type; +}; + +template struct list_av_4 +{ + typedef typename add_value::type B1; + typedef typename add_value::type B2; + typedef typename add_value::type B3; + typedef typename add_value::type B4; + typedef list4 type; +}; + +template struct list_av_5 +{ + typedef typename add_value::type B1; + typedef typename add_value::type B2; + typedef typename add_value::type B3; + typedef typename add_value::type B4; + typedef typename add_value::type B5; + typedef list5 type; +}; + +template struct list_av_6 +{ + typedef typename add_value::type B1; + typedef typename add_value::type B2; + typedef typename add_value::type B3; + typedef typename add_value::type B4; + typedef typename add_value::type B5; + typedef typename add_value::type B6; + typedef list6 type; +}; + +template struct list_av_7 +{ + typedef typename add_value::type B1; + typedef typename add_value::type B2; + typedef typename add_value::type B3; + typedef typename add_value::type B4; + typedef typename add_value::type B5; + typedef typename add_value::type B6; + typedef typename add_value::type B7; + typedef list7 type; +}; + +template struct list_av_8 +{ + typedef typename add_value::type B1; + typedef typename add_value::type B2; + typedef typename add_value::type B3; + typedef typename add_value::type B4; + typedef typename add_value::type B5; + typedef typename add_value::type B6; + typedef typename add_value::type B7; + typedef typename add_value::type B8; + typedef list8 type; +}; + +template struct list_av_9 +{ + typedef typename add_value::type B1; + typedef typename add_value::type B2; + typedef typename add_value::type B3; + typedef typename add_value::type B4; + typedef typename add_value::type B5; + typedef typename add_value::type B6; + typedef typename add_value::type B7; + typedef typename add_value::type B8; + typedef typename add_value::type B9; + typedef list9 type; +}; + +// operator! + +struct logical_not +{ + template bool operator()(V const & v) const { return !v; } +}; + +template + bind_t< bool, logical_not, list1< bind_t > > + operator! (bind_t const & f) +{ + typedef list1< bind_t > list_type; + return bind_t ( logical_not(), list_type(f) ); +} + +// relational operators + +#define BOOST_BIND_OPERATOR( op, name ) \ +\ +struct name \ +{ \ + template bool operator()(V const & v, W const & w) const { return v op w; } \ +}; \ + \ +template \ + bind_t< bool, name, list2< bind_t, typename add_value::type > > \ + operator op (bind_t const & f, A2 a2) \ +{ \ + typedef typename add_value::type B2; \ + typedef list2< bind_t, B2> list_type; \ + return bind_t ( name(), list_type(f, a2) ); \ +} + +BOOST_BIND_OPERATOR( ==, equal ) +BOOST_BIND_OPERATOR( !=, not_equal ) + +BOOST_BIND_OPERATOR( <, less ) +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) + +// resolve ambiguity with rel_ops + +#define BOOST_BIND_OPERATOR( op, name ) \ +\ +template \ + bind_t< bool, name, list2< bind_t, bind_t > > \ + operator op (bind_t const & f, bind_t const & g) \ +{ \ + typedef list2< bind_t, bind_t > list_type; \ + return bind_t ( name(), list_type(f, g) ); \ +} + +BOOST_BIND_OPERATOR( !=, not_equal ) +BOOST_BIND_OPERATOR( <=, less_equal ) +BOOST_BIND_OPERATOR( >, greater ) +BOOST_BIND_OPERATOR( >=, greater_equal ) + +#endif + +// visit_each, ADL + +#if !defined( BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP ) && !defined( __BORLANDC__ ) \ + && !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3) + +template void visit_each( V & v, value const & t, int ) +{ + using boost::visit_each; + BOOST_BIND_VISIT_EACH( v, t.get(), 0 ); +} + +template void visit_each( V & v, bind_t const & t, int ) +{ + t.accept( v ); +} + +#endif + +} // namespace _bi + +// visit_each, no ADL + +#if defined( BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP ) || defined( __BORLANDC__ ) \ + || (defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3) + +template void visit_each( V & v, _bi::value const & t, int ) +{ + BOOST_BIND_VISIT_EACH( v, t.get(), 0 ); +} + +template void visit_each( V & v, _bi::bind_t const & t, int ) +{ + t.accept( v ); +} + +#endif + +// is_bind_expression + +template< class T > struct is_bind_expression +{ + enum _vt { value = 0 }; +}; + +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) + +template< class R, class F, class L > struct is_bind_expression< _bi::bind_t< R, F, L > > +{ + enum _vt { value = 1 }; +}; + +#endif + +// bind + +#ifndef BOOST_BIND +#define BOOST_BIND bind +#endif + +// generic function objects + +template + _bi::bind_t + BOOST_BIND(F f) +{ + typedef _bi::list0 list_type; + return _bi::bind_t (f, list_type()); +} + +template + _bi::bind_t::type> + BOOST_BIND(F f, A1 a1) +{ + typedef typename _bi::list_av_1::type list_type; + return _bi::bind_t (f, list_type(a1)); +} + +template + _bi::bind_t::type> + BOOST_BIND(F f, A1 a1, A2 a2) +{ + typedef typename _bi::list_av_2::type list_type; + return _bi::bind_t (f, list_type(a1, a2)); +} + +template + _bi::bind_t::type> + BOOST_BIND(F f, A1 a1, A2 a2, A3 a3) +{ + typedef typename _bi::list_av_3::type list_type; + return _bi::bind_t(f, list_type(a1, a2, a3)); +} + +template + _bi::bind_t::type> + BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4) +{ + typedef typename _bi::list_av_4::type list_type; + return _bi::bind_t(f, list_type(a1, a2, a3, a4)); +} + +template + _bi::bind_t::type> + BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) +{ + typedef typename _bi::list_av_5::type list_type; + return _bi::bind_t(f, list_type(a1, a2, a3, a4, a5)); +} + +template + _bi::bind_t::type> + BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) +{ + typedef typename _bi::list_av_6::type list_type; + return _bi::bind_t(f, list_type(a1, a2, a3, a4, a5, a6)); +} + +template + _bi::bind_t::type> + BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) +{ + typedef typename _bi::list_av_7::type list_type; + return _bi::bind_t(f, list_type(a1, a2, a3, a4, a5, a6, a7)); +} + +template + _bi::bind_t::type> + BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) +{ + typedef typename _bi::list_av_8::type list_type; + return _bi::bind_t(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8)); +} + +template + _bi::bind_t::type> + BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) +{ + typedef typename _bi::list_av_9::type list_type; + return _bi::bind_t(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9)); +} + +// generic function objects, alternative syntax + +template + _bi::bind_t + BOOST_BIND(boost::type, F f) +{ + typedef _bi::list0 list_type; + return _bi::bind_t (f, list_type()); +} + +template + _bi::bind_t::type> + BOOST_BIND(boost::type, F f, A1 a1) +{ + typedef typename _bi::list_av_1::type list_type; + return _bi::bind_t (f, list_type(a1)); +} + +template + _bi::bind_t::type> + BOOST_BIND(boost::type, F f, A1 a1, A2 a2) +{ + typedef typename _bi::list_av_2::type list_type; + return _bi::bind_t (f, list_type(a1, a2)); +} + +template + _bi::bind_t::type> + BOOST_BIND(boost::type, F f, A1 a1, A2 a2, A3 a3) +{ + typedef typename _bi::list_av_3::type list_type; + return _bi::bind_t(f, list_type(a1, a2, a3)); +} + +template + _bi::bind_t::type> + BOOST_BIND(boost::type, F f, A1 a1, A2 a2, A3 a3, A4 a4) +{ + typedef typename _bi::list_av_4::type list_type; + return _bi::bind_t(f, list_type(a1, a2, a3, a4)); +} + +template + _bi::bind_t::type> + BOOST_BIND(boost::type, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) +{ + typedef typename _bi::list_av_5::type list_type; + return _bi::bind_t(f, list_type(a1, a2, a3, a4, a5)); +} + +template + _bi::bind_t::type> + BOOST_BIND(boost::type, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) +{ + typedef typename _bi::list_av_6::type list_type; + return _bi::bind_t(f, list_type(a1, a2, a3, a4, a5, a6)); +} + +template + _bi::bind_t::type> + BOOST_BIND(boost::type, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) +{ + typedef typename _bi::list_av_7::type list_type; + return _bi::bind_t(f, list_type(a1, a2, a3, a4, a5, a6, a7)); +} + +template + _bi::bind_t::type> + BOOST_BIND(boost::type, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) +{ + typedef typename _bi::list_av_8::type list_type; + return _bi::bind_t(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8)); +} + +template + _bi::bind_t::type> + BOOST_BIND(boost::type, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) +{ + typedef typename _bi::list_av_9::type list_type; + return _bi::bind_t(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9)); +} + +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) + +// adaptable function objects + +template + _bi::bind_t<_bi::unspecified, F, _bi::list0> + BOOST_BIND(F f) +{ + typedef _bi::list0 list_type; + return _bi::bind_t<_bi::unspecified, F, list_type> (f, list_type()); +} + +template + _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_1::type> + BOOST_BIND(F f, A1 a1) +{ + typedef typename _bi::list_av_1::type list_type; + return _bi::bind_t<_bi::unspecified, F, list_type> (f, list_type(a1)); +} + +template + _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_2::type> + BOOST_BIND(F f, A1 a1, A2 a2) +{ + typedef typename _bi::list_av_2::type list_type; + return _bi::bind_t<_bi::unspecified, F, list_type> (f, list_type(a1, a2)); +} + +template + _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_3::type> + BOOST_BIND(F f, A1 a1, A2 a2, A3 a3) +{ + typedef typename _bi::list_av_3::type list_type; + return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3)); +} + +template + _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_4::type> + BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4) +{ + typedef typename _bi::list_av_4::type list_type; + return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4)); +} + +template + _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_5::type> + BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) +{ + typedef typename _bi::list_av_5::type list_type; + return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5)); +} + +template + _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_6::type> + BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) +{ + typedef typename _bi::list_av_6::type list_type; + return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6)); +} + +template + _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_7::type> + BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) +{ + typedef typename _bi::list_av_7::type list_type; + return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7)); +} + +template + _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_8::type> + BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) +{ + typedef typename _bi::list_av_8::type list_type; + return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8)); +} + +template + _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_9::type> + BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) +{ + typedef typename _bi::list_av_9::type list_type; + return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9)); +} + +#endif // !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) + +// function pointers + +#define BOOST_BIND_CC +#define BOOST_BIND_ST + +#include + +#undef BOOST_BIND_CC +#undef BOOST_BIND_ST + +#ifdef BOOST_BIND_ENABLE_STDCALL + +#define BOOST_BIND_CC __stdcall +#define BOOST_BIND_ST + +#include + +#undef BOOST_BIND_CC +#undef BOOST_BIND_ST + +#endif + +#ifdef BOOST_BIND_ENABLE_FASTCALL + +#define BOOST_BIND_CC __fastcall +#define BOOST_BIND_ST + +#include + +#undef BOOST_BIND_CC +#undef BOOST_BIND_ST + +#endif + +#ifdef BOOST_BIND_ENABLE_PASCAL + +#define BOOST_BIND_ST pascal +#define BOOST_BIND_CC + +#include + +#undef BOOST_BIND_ST +#undef BOOST_BIND_CC + +#endif + +// member function pointers + +#define BOOST_BIND_MF_NAME(X) X +#define BOOST_BIND_MF_CC + +#include +#include + +#undef BOOST_BIND_MF_NAME +#undef BOOST_BIND_MF_CC + +#ifdef BOOST_MEM_FN_ENABLE_CDECL + +#define BOOST_BIND_MF_NAME(X) X##_cdecl +#define BOOST_BIND_MF_CC __cdecl + +#include +#include + +#undef BOOST_BIND_MF_NAME +#undef BOOST_BIND_MF_CC + +#endif + +#ifdef BOOST_MEM_FN_ENABLE_STDCALL + +#define BOOST_BIND_MF_NAME(X) X##_stdcall +#define BOOST_BIND_MF_CC __stdcall + +#include +#include + +#undef BOOST_BIND_MF_NAME +#undef BOOST_BIND_MF_CC + +#endif + +#ifdef BOOST_MEM_FN_ENABLE_FASTCALL + +#define BOOST_BIND_MF_NAME(X) X##_fastcall +#define BOOST_BIND_MF_CC __fastcall + +#include +#include + +#undef BOOST_BIND_MF_NAME +#undef BOOST_BIND_MF_CC + +#endif + +// data member pointers + +#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \ + || ( defined(__BORLANDC__) && BOOST_WORKAROUND( __BORLANDC__, < 0x600 ) ) + +template +_bi::bind_t< R, _mfi::dm, typename _bi::list_av_1::type > + BOOST_BIND(R T::*f, A1 a1) +{ + typedef _mfi::dm F; + typedef typename _bi::list_av_1::type list_type; + return _bi::bind_t( F(f), list_type(a1) ); +} + +#else + +namespace _bi +{ + +template< class Pm, int I > struct add_cref; + +template< class M, class T > struct add_cref< M T::*, 0 > +{ + typedef M type; +}; + +template< class M, class T > struct add_cref< M T::*, 1 > +{ + typedef M const & type; +}; + +template< class R, class T > struct add_cref< R (T::*) (), 1 > +{ + typedef void type; +}; + +#if !( defined(__IBMCPP__) && BOOST_WORKAROUND( __IBMCPP__, BOOST_TESTED_AT(600) ) ) + +template< class R, class T > struct add_cref< R (T::*) () const, 1 > +{ + typedef void type; +}; + +#endif // __IBMCPP__ + +template struct isref +{ + enum value_type { value = 0 }; +}; + +template struct isref< R& > +{ + enum value_type { value = 1 }; +}; + +template struct isref< R* > +{ + enum value_type { value = 1 }; +}; + +template struct dm_result +{ + typedef typename add_cref< Pm, 1 >::type type; +}; + +template struct dm_result< Pm, bind_t > +{ + typedef typename bind_t::result_type result_type; + typedef typename add_cref< Pm, isref< result_type >::value >::type type; +}; + +} // namespace _bi + +template< class A1, class M, class T > + +_bi::bind_t< + typename _bi::dm_result< M T::*, A1 >::type, + _mfi::dm, + typename _bi::list_av_1::type +> + +BOOST_BIND( M T::*f, A1 a1 ) +{ + typedef typename _bi::dm_result< M T::*, A1 >::type result_type; + typedef _mfi::dm F; + typedef typename _bi::list_av_1::type list_type; + return _bi::bind_t< result_type, F, list_type >( F( f ), list_type( a1 ) ); +} + +#endif + +} // namespace boost + +#ifndef BOOST_BIND_NO_PLACEHOLDERS + +# include + +#endif + +#ifdef BOOST_MSVC +# pragma warning(default: 4512) // assignment operator could not be generated +# pragma warning(pop) +#endif + +#endif // #ifndef BOOST_BIND_HPP_INCLUDED From 4000680b6a700f64227fafb15b240e548f99a445 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 28 Feb 2009 21:27:51 +0000 Subject: [PATCH 31/62] Copy mem_fn.hpp to bind/ [SVN r51488] --- include/boost/bind/mem_fn.hpp | 389 ++++++++++++++++++++++++++++++++++ 1 file changed, 389 insertions(+) create mode 100644 include/boost/bind/mem_fn.hpp diff --git a/include/boost/bind/mem_fn.hpp b/include/boost/bind/mem_fn.hpp new file mode 100644 index 0000000..9695f57 --- /dev/null +++ b/include/boost/bind/mem_fn.hpp @@ -0,0 +1,389 @@ +#ifndef BOOST_MEM_FN_HPP_INCLUDED +#define BOOST_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 +#include +#include + +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 struct mf +{ + +#define BOOST_MEM_FN_RETURN return + +#define BOOST_MEM_FN_NAME(X) inner_##X +#define BOOST_MEM_FN_CC + +#include + +#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 + +#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 + +#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 + +#undef BOOST_MEM_FN_CC +#undef BOOST_MEM_FN_NAME + +#endif + +#undef BOOST_MEM_FN_RETURN + +}; // struct mf + +template<> struct mf +{ + +#define BOOST_MEM_FN_RETURN + +#define BOOST_MEM_FN_NAME(X) inner_##X +#define BOOST_MEM_FN_CC + +#include + +#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 + +#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 + +#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 + +#undef BOOST_MEM_FN_CC +#undef BOOST_MEM_FN_NAME + +#endif + +#undef BOOST_MEM_FN_RETURN + +}; // struct mf + +#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 + +#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 + +#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 + +#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 + +#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 + +#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 + +#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 + +#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 + +#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 + +#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 + +#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 + +#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 + +#undef BOOST_MEM_FN_NAME +#undef BOOST_MEM_FN_CC + +#endif + +// data member support + +namespace _mfi +{ + +template class dm +{ +public: + + typedef R const & result_type; + typedef T const * argument_type; + +private: + + typedef R (T::*F); + F f_; + + template R const & call(U & u, T const *) const + { + return (u.*f_); + } + + template 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 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 _mfi::dm mem_fn(R T::*f) +{ + return _mfi::dm(f); +} + +} // namespace boost + +#endif // #ifndef BOOST_MEM_FN_HPP_INCLUDED From 5d49fb45d06b36dee5b0d6a6055f5bf0b3db301d Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 28 Feb 2009 21:40:27 +0000 Subject: [PATCH 32/62] Make bind.hpp and mem_fn.hpp forward to bind/bind.hpp and bind/mem_fn.hpp. (Ref #2238) [SVN r51489] --- include/boost/bind.hpp | 1705 +-------------------------------- include/boost/bind/bind.hpp | 6 +- include/boost/bind/mem_fn.hpp | 6 +- include/boost/mem_fn.hpp | 375 +------- 4 files changed, 16 insertions(+), 2076 deletions(-) diff --git a/include/boost/bind.hpp b/include/boost/bind.hpp index 07b84d3..fd3421e 100644 --- a/include/boost/bind.hpp +++ b/include/boost/bind.hpp @@ -10,1710 +10,15 @@ // // bind.hpp - binds function objects to arguments // -// Copyright (c) 2001-2004 Peter Dimov and Multi Media Ltd. -// Copyright (c) 2001 David Abrahams -// Copyright (c) 2005 Peter Dimov +// 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/bind.html for documentation. // -#include -#include -#include -#include -#include -#include -#include -#include - -// Borland-specific bug, visit_each() silently fails to produce code - -#if defined(__BORLANDC__) -# define BOOST_BIND_VISIT_EACH boost::visit_each -#else -# define BOOST_BIND_VISIT_EACH visit_each -#endif - -#include - -#ifdef BOOST_MSVC -# pragma warning(push) -# pragma warning(disable: 4512) // assignment operator could not be generated -#endif - -namespace boost -{ - -namespace _bi // implementation details -{ - -// result_traits - -template struct result_traits -{ - typedef R type; -}; - -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) - -struct unspecified {}; - -template struct result_traits -{ - typedef typename F::result_type type; -}; - -template struct result_traits< unspecified, reference_wrapper > -{ - typedef typename F::result_type type; -}; - -#endif - -// ref_compare - -template bool ref_compare( T const & a, T const & b, long ) -{ - return a == b; -} - -template bool ref_compare( arg const &, arg const &, int ) -{ - return true; -} - -template bool ref_compare( arg (*) (), arg (*) (), int ) -{ - return true; -} - -template bool ref_compare( reference_wrapper const & a, reference_wrapper const & b, int ) -{ - return a.get_pointer() == b.get_pointer(); -} - -// bind_t forward declaration for listN - -template class bind_t; - -// value - -template class value -{ -public: - - value(T const & t): t_(t) {} - - T & get() { return t_; } - T const & get() const { return t_; } - - bool operator==(value const & rhs) const - { - return t_ == rhs.t_; - } - -private: - - T t_; -}; - -// type - -template class type {}; - -// unwrap - -template struct unwrapper -{ - static inline F & unwrap( F & f, long ) - { - return f; - } - - template static inline F2 & unwrap( reference_wrapper rf, int ) - { - return rf.get(); - } - - template static inline _mfi::dm unwrap( R T::* pm, int ) - { - return _mfi::dm( pm ); - } -}; - -// listN - -class list0 -{ -public: - - list0() {} - - template T & operator[] (_bi::value & v) const { return v.get(); } - - template T const & operator[] (_bi::value const & v) const { return v.get(); } - - template T & operator[] (reference_wrapper const & v) const { return v.get(); } - - template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } - - template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } - - template R operator()(type, F & f, A &, long) - { - return unwrapper::unwrap(f, 0)(); - } - - template R operator()(type, F const & f, A &, long) const - { - return unwrapper::unwrap(f, 0)(); - } - - template void operator()(type, F & f, A &, int) - { - unwrapper::unwrap(f, 0)(); - } - - template void operator()(type, F const & f, A &, int) const - { - unwrapper::unwrap(f, 0)(); - } - - template void accept(V &) const - { - } - - bool operator==(list0 const &) const - { - return true; - } -}; - -template< class A1 > class list1: private storage1< A1 > -{ -private: - - typedef storage1< A1 > base_type; - -public: - - explicit list1( A1 a1 ): base_type( a1 ) {} - - A1 operator[] (boost::arg<1>) const { return base_type::a1_; } - - A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; } - - template T & operator[] ( _bi::value & v ) const { return v.get(); } - - template T const & operator[] ( _bi::value const & v ) const { return v.get(); } - - template T & operator[] (reference_wrapper const & v) const { return v.get(); } - - template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } - - template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } - - template R operator()(type, F & f, A & a, long) - { - return unwrapper::unwrap(f, 0)(a[base_type::a1_]); - } - - template R operator()(type, F const & f, A & a, long) const - { - return unwrapper::unwrap(f, 0)(a[base_type::a1_]); - } - - template void operator()(type, F & f, A & a, int) - { - unwrapper::unwrap(f, 0)(a[base_type::a1_]); - } - - template void operator()(type, F const & f, A & a, int) const - { - unwrapper::unwrap(f, 0)(a[base_type::a1_]); - } - - template void accept(V & v) const - { - base_type::accept(v); - } - - bool operator==(list1 const & rhs) const - { - return ref_compare(base_type::a1_, rhs.a1_, 0); - } -}; - -struct logical_and; -struct logical_or; - -template< class A1, class A2 > class list2: private storage2< A1, A2 > -{ -private: - - typedef storage2< A1, A2 > base_type; - -public: - - list2( A1 a1, A2 a2 ): base_type( a1, a2 ) {} - - A1 operator[] (boost::arg<1>) const { return base_type::a1_; } - A2 operator[] (boost::arg<2>) const { return base_type::a2_; } - - A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; } - A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; } - - template T & operator[] (_bi::value & v) const { return v.get(); } - - template T const & operator[] (_bi::value const & v) const { return v.get(); } - - template T & operator[] (reference_wrapper const & v) const { return v.get(); } - - template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } - - template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } - - template R operator()(type, F & f, A & a, long) - { - return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]); - } - - template R operator()(type, F const & f, A & a, long) const - { - return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]); - } - - template void operator()(type, F & f, A & a, int) - { - unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]); - } - - template void operator()(type, F const & f, A & a, int) const - { - unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]); - } - - template bool operator()( type, logical_and & /*f*/, A & a, int ) - { - return a[ base_type::a1_ ] && a[ base_type::a2_ ]; - } - - template bool operator()( type, logical_and const & /*f*/, A & a, int ) const - { - return a[ base_type::a1_ ] && a[ base_type::a2_ ]; - } - - template bool operator()( type, logical_or & /*f*/, A & a, int ) - { - return a[ base_type::a1_ ] || a[ base_type::a2_ ]; - } - - template bool operator()( type, logical_or const & /*f*/, A & a, int ) const - { - return a[ base_type::a1_ ] || a[ base_type::a2_ ]; - } - - template void accept(V & v) const - { - base_type::accept(v); - } - - bool operator==(list2 const & rhs) const - { - return ref_compare(base_type::a1_, rhs.a1_, 0) && ref_compare(base_type::a2_, rhs.a2_, 0); - } -}; - -template< class A1, class A2, class A3 > class list3: private storage3< A1, A2, A3 > -{ -private: - - typedef storage3< A1, A2, A3 > base_type; - -public: - - list3( A1 a1, A2 a2, A3 a3 ): base_type( a1, a2, a3 ) {} - - A1 operator[] (boost::arg<1>) const { return base_type::a1_; } - A2 operator[] (boost::arg<2>) const { return base_type::a2_; } - A3 operator[] (boost::arg<3>) const { return base_type::a3_; } - - A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; } - A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; } - A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; } - - template T & operator[] (_bi::value & v) const { return v.get(); } - - template T const & operator[] (_bi::value const & v) const { return v.get(); } - - template T & operator[] (reference_wrapper const & v) const { return v.get(); } - - template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } - - template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } - - template R operator()(type, F & f, A & a, long) - { - return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]); - } - - template R operator()(type, F const & f, A & a, long) const - { - return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]); - } - - template void operator()(type, F & f, A & a, int) - { - unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]); - } - - template void operator()(type, F const & f, A & a, int) const - { - unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]); - } - - template void accept(V & v) const - { - base_type::accept(v); - } - - bool operator==(list3 const & rhs) const - { - return - - ref_compare( base_type::a1_, rhs.a1_, 0 ) && - ref_compare( base_type::a2_, rhs.a2_, 0 ) && - ref_compare( base_type::a3_, rhs.a3_, 0 ); - } -}; - -template< class A1, class A2, class A3, class A4 > class list4: private storage4< A1, A2, A3, A4 > -{ -private: - - typedef storage4< A1, A2, A3, A4 > base_type; - -public: - - list4( A1 a1, A2 a2, A3 a3, A4 a4 ): base_type( a1, a2, a3, a4 ) {} - - A1 operator[] (boost::arg<1>) const { return base_type::a1_; } - A2 operator[] (boost::arg<2>) const { return base_type::a2_; } - A3 operator[] (boost::arg<3>) const { return base_type::a3_; } - A4 operator[] (boost::arg<4>) const { return base_type::a4_; } - - A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; } - A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; } - A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; } - A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; } - - template T & operator[] (_bi::value & v) const { return v.get(); } - - template T const & operator[] (_bi::value const & v) const { return v.get(); } - - template T & operator[] (reference_wrapper const & v) const { return v.get(); } - - template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } - - template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } - - template R operator()(type, F & f, A & a, long) - { - return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_]); - } - - template R operator()(type, F const & f, A & a, long) const - { - return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_]); - } - - template void operator()(type, F & f, A & a, int) - { - unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_]); - } - - template void operator()(type, F const & f, A & a, int) const - { - unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_]); - } - - template void accept(V & v) const - { - base_type::accept(v); - } - - bool operator==(list4 const & rhs) const - { - return - - ref_compare( base_type::a1_, rhs.a1_, 0 ) && - ref_compare( base_type::a2_, rhs.a2_, 0 ) && - ref_compare( base_type::a3_, rhs.a3_, 0 ) && - ref_compare( base_type::a4_, rhs.a4_, 0 ); - } -}; - -template< class A1, class A2, class A3, class A4, class A5 > class list5: private storage5< A1, A2, A3, A4, A5 > -{ -private: - - typedef storage5< A1, A2, A3, A4, A5 > base_type; - -public: - - list5( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5 ): base_type( a1, a2, a3, a4, a5 ) {} - - A1 operator[] (boost::arg<1>) const { return base_type::a1_; } - A2 operator[] (boost::arg<2>) const { return base_type::a2_; } - A3 operator[] (boost::arg<3>) const { return base_type::a3_; } - A4 operator[] (boost::arg<4>) const { return base_type::a4_; } - A5 operator[] (boost::arg<5>) const { return base_type::a5_; } - - A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; } - A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; } - A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; } - A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; } - A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; } - - template T & operator[] (_bi::value & v) const { return v.get(); } - - template T const & operator[] (_bi::value const & v) const { return v.get(); } - - template T & operator[] (reference_wrapper const & v) const { return v.get(); } - - template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } - - template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } - - template R operator()(type, F & f, A & a, long) - { - return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_]); - } - - template R operator()(type, F const & f, A & a, long) const - { - return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_]); - } - - template void operator()(type, F & f, A & a, int) - { - unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_]); - } - - template void operator()(type, F const & f, A & a, int) const - { - unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_]); - } - - template void accept(V & v) const - { - base_type::accept(v); - } - - bool operator==(list5 const & rhs) const - { - return - - ref_compare( base_type::a1_, rhs.a1_, 0 ) && - ref_compare( base_type::a2_, rhs.a2_, 0 ) && - ref_compare( base_type::a3_, rhs.a3_, 0 ) && - ref_compare( base_type::a4_, rhs.a4_, 0 ) && - ref_compare( base_type::a5_, rhs.a5_, 0 ); - } -}; - -template class list6: private storage6< A1, A2, A3, A4, A5, A6 > -{ -private: - - typedef storage6< A1, A2, A3, A4, A5, A6 > base_type; - -public: - - list6( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6 ): base_type( a1, a2, a3, a4, a5, a6 ) {} - - A1 operator[] (boost::arg<1>) const { return base_type::a1_; } - A2 operator[] (boost::arg<2>) const { return base_type::a2_; } - A3 operator[] (boost::arg<3>) const { return base_type::a3_; } - A4 operator[] (boost::arg<4>) const { return base_type::a4_; } - A5 operator[] (boost::arg<5>) const { return base_type::a5_; } - A6 operator[] (boost::arg<6>) const { return base_type::a6_; } - - A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; } - A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; } - A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; } - A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; } - A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; } - A6 operator[] (boost::arg<6> (*) ()) const { return base_type::a6_; } - - template T & operator[] (_bi::value & v) const { return v.get(); } - - template T const & operator[] (_bi::value const & v) const { return v.get(); } - - template T & operator[] (reference_wrapper const & v) const { return v.get(); } - - template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } - - template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } - - template R operator()(type, F & f, A & a, long) - { - return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_]); - } - - template R operator()(type, F const & f, A & a, long) const - { - return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_]); - } - - template void operator()(type, F & f, A & a, int) - { - unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_]); - } - - template void operator()(type, F const & f, A & a, int) const - { - unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_]); - } - - template void accept(V & v) const - { - base_type::accept(v); - } - - bool operator==(list6 const & rhs) const - { - return - - ref_compare( base_type::a1_, rhs.a1_, 0 ) && - ref_compare( base_type::a2_, rhs.a2_, 0 ) && - ref_compare( base_type::a3_, rhs.a3_, 0 ) && - ref_compare( base_type::a4_, rhs.a4_, 0 ) && - ref_compare( base_type::a5_, rhs.a5_, 0 ) && - ref_compare( base_type::a6_, rhs.a6_, 0 ); - } -}; - -template class list7: private storage7< A1, A2, A3, A4, A5, A6, A7 > -{ -private: - - typedef storage7< A1, A2, A3, A4, A5, A6, A7 > base_type; - -public: - - list7( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7 ): base_type( a1, a2, a3, a4, a5, a6, a7 ) {} - - A1 operator[] (boost::arg<1>) const { return base_type::a1_; } - A2 operator[] (boost::arg<2>) const { return base_type::a2_; } - A3 operator[] (boost::arg<3>) const { return base_type::a3_; } - A4 operator[] (boost::arg<4>) const { return base_type::a4_; } - A5 operator[] (boost::arg<5>) const { return base_type::a5_; } - A6 operator[] (boost::arg<6>) const { return base_type::a6_; } - A7 operator[] (boost::arg<7>) const { return base_type::a7_; } - - A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; } - A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; } - A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; } - A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; } - A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; } - A6 operator[] (boost::arg<6> (*) ()) const { return base_type::a6_; } - A7 operator[] (boost::arg<7> (*) ()) const { return base_type::a7_; } - - template T & operator[] (_bi::value & v) const { return v.get(); } - - template T const & operator[] (_bi::value const & v) const { return v.get(); } - - template T & operator[] (reference_wrapper const & v) const { return v.get(); } - - template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } - - template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } - - template R operator()(type, F & f, A & a, long) - { - return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_]); - } - - template R operator()(type, F const & f, A & a, long) const - { - return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_]); - } - - template void operator()(type, F & f, A & a, int) - { - unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_]); - } - - template void operator()(type, F const & f, A & a, int) const - { - unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_]); - } - - template void accept(V & v) const - { - base_type::accept(v); - } - - bool operator==(list7 const & rhs) const - { - return - - ref_compare( base_type::a1_, rhs.a1_, 0 ) && - ref_compare( base_type::a2_, rhs.a2_, 0 ) && - ref_compare( base_type::a3_, rhs.a3_, 0 ) && - ref_compare( base_type::a4_, rhs.a4_, 0 ) && - ref_compare( base_type::a5_, rhs.a5_, 0 ) && - ref_compare( base_type::a6_, rhs.a6_, 0 ) && - ref_compare( base_type::a7_, rhs.a7_, 0 ); - } -}; - -template< class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > class list8: private storage8< A1, A2, A3, A4, A5, A6, A7, A8 > -{ -private: - - typedef storage8< A1, A2, A3, A4, A5, A6, A7, A8 > base_type; - -public: - - list8( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8 ): base_type( a1, a2, a3, a4, a5, a6, a7, a8 ) {} - - A1 operator[] (boost::arg<1>) const { return base_type::a1_; } - A2 operator[] (boost::arg<2>) const { return base_type::a2_; } - A3 operator[] (boost::arg<3>) const { return base_type::a3_; } - A4 operator[] (boost::arg<4>) const { return base_type::a4_; } - A5 operator[] (boost::arg<5>) const { return base_type::a5_; } - A6 operator[] (boost::arg<6>) const { return base_type::a6_; } - A7 operator[] (boost::arg<7>) const { return base_type::a7_; } - A8 operator[] (boost::arg<8>) const { return base_type::a8_; } - - A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; } - A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; } - A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; } - A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; } - A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; } - A6 operator[] (boost::arg<6> (*) ()) const { return base_type::a6_; } - A7 operator[] (boost::arg<7> (*) ()) const { return base_type::a7_; } - A8 operator[] (boost::arg<8> (*) ()) const { return base_type::a8_; } - - template T & operator[] (_bi::value & v) const { return v.get(); } - - template T const & operator[] (_bi::value const & v) const { return v.get(); } - - template T & operator[] (reference_wrapper const & v) const { return v.get(); } - - template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } - - template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } - - template R operator()(type, F & f, A & a, long) - { - return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_]); - } - - template R operator()(type, F const & f, A & a, long) const - { - return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_]); - } - - template void operator()(type, F & f, A & a, int) - { - unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_]); - } - - template void operator()(type, F const & f, A & a, int) const - { - unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_]); - } - - template void accept(V & v) const - { - base_type::accept(v); - } - - bool operator==(list8 const & rhs) const - { - return - - ref_compare( base_type::a1_, rhs.a1_, 0 ) && - ref_compare( base_type::a2_, rhs.a2_, 0 ) && - ref_compare( base_type::a3_, rhs.a3_, 0 ) && - ref_compare( base_type::a4_, rhs.a4_, 0 ) && - ref_compare( base_type::a5_, rhs.a5_, 0 ) && - ref_compare( base_type::a6_, rhs.a6_, 0 ) && - ref_compare( base_type::a7_, rhs.a7_, 0 ) && - ref_compare( base_type::a8_, rhs.a8_, 0 ); - } -}; - -template class list9: private storage9< A1, A2, A3, A4, A5, A6, A7, A8, A9 > -{ -private: - - typedef storage9< A1, A2, A3, A4, A5, A6, A7, A8, A9 > base_type; - -public: - - list9( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9 ): base_type( a1, a2, a3, a4, a5, a6, a7, a8, a9 ) {} - - A1 operator[] (boost::arg<1>) const { return base_type::a1_; } - A2 operator[] (boost::arg<2>) const { return base_type::a2_; } - A3 operator[] (boost::arg<3>) const { return base_type::a3_; } - A4 operator[] (boost::arg<4>) const { return base_type::a4_; } - A5 operator[] (boost::arg<5>) const { return base_type::a5_; } - A6 operator[] (boost::arg<6>) const { return base_type::a6_; } - A7 operator[] (boost::arg<7>) const { return base_type::a7_; } - A8 operator[] (boost::arg<8>) const { return base_type::a8_; } - A9 operator[] (boost::arg<9>) const { return base_type::a9_; } - - A1 operator[] (boost::arg<1> (*) ()) const { return base_type::a1_; } - A2 operator[] (boost::arg<2> (*) ()) const { return base_type::a2_; } - A3 operator[] (boost::arg<3> (*) ()) const { return base_type::a3_; } - A4 operator[] (boost::arg<4> (*) ()) const { return base_type::a4_; } - A5 operator[] (boost::arg<5> (*) ()) const { return base_type::a5_; } - A6 operator[] (boost::arg<6> (*) ()) const { return base_type::a6_; } - A7 operator[] (boost::arg<7> (*) ()) const { return base_type::a7_; } - A8 operator[] (boost::arg<8> (*) ()) const { return base_type::a8_; } - A9 operator[] (boost::arg<9> (*) ()) const { return base_type::a9_; } - - template T & operator[] (_bi::value & v) const { return v.get(); } - - template T const & operator[] (_bi::value const & v) const { return v.get(); } - - template T & operator[] (reference_wrapper const & v) const { return v.get(); } - - template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } - - template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } - - template R operator()(type, F & f, A & a, long) - { - return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_], a[base_type::a9_]); - } - - template R operator()(type, F const & f, A & a, long) const - { - return unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_], a[base_type::a9_]); - } - - template void operator()(type, F & f, A & a, int) - { - unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_], a[base_type::a9_]); - } - - template void operator()(type, F const & f, A & a, int) const - { - unwrapper::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_], a[base_type::a6_], a[base_type::a7_], a[base_type::a8_], a[base_type::a9_]); - } - - template void accept(V & v) const - { - base_type::accept(v); - } - - bool operator==(list9 const & rhs) const - { - return - - ref_compare( base_type::a1_, rhs.a1_, 0 ) && - ref_compare( base_type::a2_, rhs.a2_, 0 ) && - ref_compare( base_type::a3_, rhs.a3_, 0 ) && - ref_compare( base_type::a4_, rhs.a4_, 0 ) && - ref_compare( base_type::a5_, rhs.a5_, 0 ) && - ref_compare( base_type::a6_, rhs.a6_, 0 ) && - ref_compare( base_type::a7_, rhs.a7_, 0 ) && - ref_compare( base_type::a8_, rhs.a8_, 0 ) && - ref_compare( base_type::a9_, rhs.a9_, 0 ); - } -}; - -// bind_t - -#ifndef BOOST_NO_VOID_RETURNS - -template class bind_t -{ -public: - - typedef bind_t this_type; - - bind_t(F f, L const & l): f_(f), l_(l) {} - -#define BOOST_BIND_RETURN return -#include -#undef BOOST_BIND_RETURN - -}; - -#else - -template struct bind_t_generator -{ - -template class implementation -{ -public: - - typedef implementation this_type; - - implementation(F f, L const & l): f_(f), l_(l) {} - -#define BOOST_BIND_RETURN return -#include -#undef BOOST_BIND_RETURN - -}; - -}; - -template<> struct bind_t_generator -{ - -template class implementation -{ -private: - - typedef void R; - -public: - - typedef implementation this_type; - - implementation(F f, L const & l): f_(f), l_(l) {} - -#define BOOST_BIND_RETURN -#include -#undef BOOST_BIND_RETURN - -}; - -}; - -template class bind_t: public bind_t_generator::BOOST_NESTED_TEMPLATE implementation -{ -public: - - bind_t(F f, L const & l): bind_t_generator::BOOST_NESTED_TEMPLATE implementation(f, l) {} - -}; - -#endif - -// function_equal - -#ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP - -// put overloads in _bi, rely on ADL - -# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING - -template bool function_equal( bind_t const & a, bind_t const & b ) -{ - return a.compare(b); -} - -# else - -template bool function_equal_impl( bind_t const & a, bind_t const & b, int ) -{ - return a.compare(b); -} - -# endif // #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING - -#else // BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP - -// put overloads in boost - -} // namespace _bi - -# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING - -template bool function_equal( _bi::bind_t const & a, _bi::bind_t const & b ) -{ - return a.compare(b); -} - -# else - -template bool function_equal_impl( _bi::bind_t const & a, _bi::bind_t const & b, int ) -{ - return a.compare(b); -} - -# endif // #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING - -namespace _bi -{ - -#endif // BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP - -// add_value - -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || (__SUNPRO_CC >= 0x530) - -#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x582) ) - -template struct add_value -{ - typedef _bi::value type; -}; - -#else - -template< class T, int I > struct add_value_2 -{ - typedef boost::arg type; -}; - -template< class T > struct add_value_2< T, 0 > -{ - typedef _bi::value< T > type; -}; - -template struct add_value -{ - typedef typename add_value_2< T, boost::is_placeholder< T >::value >::type type; -}; - -#endif - -template struct add_value< value > -{ - typedef _bi::value type; -}; - -template struct add_value< reference_wrapper > -{ - typedef reference_wrapper type; -}; - -template struct add_value< arg > -{ - typedef boost::arg type; -}; - -template struct add_value< arg (*) () > -{ - typedef boost::arg (*type) (); -}; - -template struct add_value< bind_t > -{ - typedef bind_t type; -}; - -#else - -template struct _avt_0; - -template<> struct _avt_0<1> -{ - template struct inner - { - typedef T type; - }; -}; - -template<> struct _avt_0<2> -{ - template struct inner - { - typedef value type; - }; -}; - -typedef char (&_avt_r1) [1]; -typedef char (&_avt_r2) [2]; - -template _avt_r1 _avt_f(value); -template _avt_r1 _avt_f(reference_wrapper); -template _avt_r1 _avt_f(arg); -template _avt_r1 _avt_f(arg (*) ()); -template _avt_r1 _avt_f(bind_t); - -_avt_r2 _avt_f(...); - -template struct add_value -{ - static T t(); - typedef typename _avt_0::template inner::type type; -}; - -#endif - -// list_av_N - -template struct list_av_1 -{ - typedef typename add_value::type B1; - typedef list1 type; -}; - -template struct list_av_2 -{ - typedef typename add_value::type B1; - typedef typename add_value::type B2; - typedef list2 type; -}; - -template struct list_av_3 -{ - typedef typename add_value::type B1; - typedef typename add_value::type B2; - typedef typename add_value::type B3; - typedef list3 type; -}; - -template struct list_av_4 -{ - typedef typename add_value::type B1; - typedef typename add_value::type B2; - typedef typename add_value::type B3; - typedef typename add_value::type B4; - typedef list4 type; -}; - -template struct list_av_5 -{ - typedef typename add_value::type B1; - typedef typename add_value::type B2; - typedef typename add_value::type B3; - typedef typename add_value::type B4; - typedef typename add_value::type B5; - typedef list5 type; -}; - -template struct list_av_6 -{ - typedef typename add_value::type B1; - typedef typename add_value::type B2; - typedef typename add_value::type B3; - typedef typename add_value::type B4; - typedef typename add_value::type B5; - typedef typename add_value::type B6; - typedef list6 type; -}; - -template struct list_av_7 -{ - typedef typename add_value::type B1; - typedef typename add_value::type B2; - typedef typename add_value::type B3; - typedef typename add_value::type B4; - typedef typename add_value::type B5; - typedef typename add_value::type B6; - typedef typename add_value::type B7; - typedef list7 type; -}; - -template struct list_av_8 -{ - typedef typename add_value::type B1; - typedef typename add_value::type B2; - typedef typename add_value::type B3; - typedef typename add_value::type B4; - typedef typename add_value::type B5; - typedef typename add_value::type B6; - typedef typename add_value::type B7; - typedef typename add_value::type B8; - typedef list8 type; -}; - -template struct list_av_9 -{ - typedef typename add_value::type B1; - typedef typename add_value::type B2; - typedef typename add_value::type B3; - typedef typename add_value::type B4; - typedef typename add_value::type B5; - typedef typename add_value::type B6; - typedef typename add_value::type B7; - typedef typename add_value::type B8; - typedef typename add_value::type B9; - typedef list9 type; -}; - -// operator! - -struct logical_not -{ - template bool operator()(V const & v) const { return !v; } -}; - -template - bind_t< bool, logical_not, list1< bind_t > > - operator! (bind_t const & f) -{ - typedef list1< bind_t > list_type; - return bind_t ( logical_not(), list_type(f) ); -} - -// relational operators - -#define BOOST_BIND_OPERATOR( op, name ) \ -\ -struct name \ -{ \ - template bool operator()(V const & v, W const & w) const { return v op w; } \ -}; \ - \ -template \ - bind_t< bool, name, list2< bind_t, typename add_value::type > > \ - operator op (bind_t const & f, A2 a2) \ -{ \ - typedef typename add_value::type B2; \ - typedef list2< bind_t, B2> list_type; \ - return bind_t ( name(), list_type(f, a2) ); \ -} - -BOOST_BIND_OPERATOR( ==, equal ) -BOOST_BIND_OPERATOR( !=, not_equal ) - -BOOST_BIND_OPERATOR( <, less ) -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) - -// resolve ambiguity with rel_ops - -#define BOOST_BIND_OPERATOR( op, name ) \ -\ -template \ - bind_t< bool, name, list2< bind_t, bind_t > > \ - operator op (bind_t const & f, bind_t const & g) \ -{ \ - typedef list2< bind_t, bind_t > list_type; \ - return bind_t ( name(), list_type(f, g) ); \ -} - -BOOST_BIND_OPERATOR( !=, not_equal ) -BOOST_BIND_OPERATOR( <=, less_equal ) -BOOST_BIND_OPERATOR( >, greater ) -BOOST_BIND_OPERATOR( >=, greater_equal ) - -#endif - -// visit_each, ADL - -#if !defined( BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP ) && !defined( __BORLANDC__ ) \ - && !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3) - -template void visit_each( V & v, value const & t, int ) -{ - using boost::visit_each; - BOOST_BIND_VISIT_EACH( v, t.get(), 0 ); -} - -template void visit_each( V & v, bind_t const & t, int ) -{ - t.accept( v ); -} - -#endif - -} // namespace _bi - -// visit_each, no ADL - -#if defined( BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP ) || defined( __BORLANDC__ ) \ - || (defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ <= 3) - -template void visit_each( V & v, _bi::value const & t, int ) -{ - BOOST_BIND_VISIT_EACH( v, t.get(), 0 ); -} - -template void visit_each( V & v, _bi::bind_t const & t, int ) -{ - t.accept( v ); -} - -#endif - -// is_bind_expression - -template< class T > struct is_bind_expression -{ - enum _vt { value = 0 }; -}; - -#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) - -template< class R, class F, class L > struct is_bind_expression< _bi::bind_t< R, F, L > > -{ - enum _vt { value = 1 }; -}; - -#endif - -// bind - -#ifndef BOOST_BIND -#define BOOST_BIND bind -#endif - -// generic function objects - -template - _bi::bind_t - BOOST_BIND(F f) -{ - typedef _bi::list0 list_type; - return _bi::bind_t (f, list_type()); -} - -template - _bi::bind_t::type> - BOOST_BIND(F f, A1 a1) -{ - typedef typename _bi::list_av_1::type list_type; - return _bi::bind_t (f, list_type(a1)); -} - -template - _bi::bind_t::type> - BOOST_BIND(F f, A1 a1, A2 a2) -{ - typedef typename _bi::list_av_2::type list_type; - return _bi::bind_t (f, list_type(a1, a2)); -} - -template - _bi::bind_t::type> - BOOST_BIND(F f, A1 a1, A2 a2, A3 a3) -{ - typedef typename _bi::list_av_3::type list_type; - return _bi::bind_t(f, list_type(a1, a2, a3)); -} - -template - _bi::bind_t::type> - BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4) -{ - typedef typename _bi::list_av_4::type list_type; - return _bi::bind_t(f, list_type(a1, a2, a3, a4)); -} - -template - _bi::bind_t::type> - BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) -{ - typedef typename _bi::list_av_5::type list_type; - return _bi::bind_t(f, list_type(a1, a2, a3, a4, a5)); -} - -template - _bi::bind_t::type> - BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) -{ - typedef typename _bi::list_av_6::type list_type; - return _bi::bind_t(f, list_type(a1, a2, a3, a4, a5, a6)); -} - -template - _bi::bind_t::type> - BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) -{ - typedef typename _bi::list_av_7::type list_type; - return _bi::bind_t(f, list_type(a1, a2, a3, a4, a5, a6, a7)); -} - -template - _bi::bind_t::type> - BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) -{ - typedef typename _bi::list_av_8::type list_type; - return _bi::bind_t(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8)); -} - -template - _bi::bind_t::type> - BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) -{ - typedef typename _bi::list_av_9::type list_type; - return _bi::bind_t(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9)); -} - -// generic function objects, alternative syntax - -template - _bi::bind_t - BOOST_BIND(boost::type, F f) -{ - typedef _bi::list0 list_type; - return _bi::bind_t (f, list_type()); -} - -template - _bi::bind_t::type> - BOOST_BIND(boost::type, F f, A1 a1) -{ - typedef typename _bi::list_av_1::type list_type; - return _bi::bind_t (f, list_type(a1)); -} - -template - _bi::bind_t::type> - BOOST_BIND(boost::type, F f, A1 a1, A2 a2) -{ - typedef typename _bi::list_av_2::type list_type; - return _bi::bind_t (f, list_type(a1, a2)); -} - -template - _bi::bind_t::type> - BOOST_BIND(boost::type, F f, A1 a1, A2 a2, A3 a3) -{ - typedef typename _bi::list_av_3::type list_type; - return _bi::bind_t(f, list_type(a1, a2, a3)); -} - -template - _bi::bind_t::type> - BOOST_BIND(boost::type, F f, A1 a1, A2 a2, A3 a3, A4 a4) -{ - typedef typename _bi::list_av_4::type list_type; - return _bi::bind_t(f, list_type(a1, a2, a3, a4)); -} - -template - _bi::bind_t::type> - BOOST_BIND(boost::type, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) -{ - typedef typename _bi::list_av_5::type list_type; - return _bi::bind_t(f, list_type(a1, a2, a3, a4, a5)); -} - -template - _bi::bind_t::type> - BOOST_BIND(boost::type, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) -{ - typedef typename _bi::list_av_6::type list_type; - return _bi::bind_t(f, list_type(a1, a2, a3, a4, a5, a6)); -} - -template - _bi::bind_t::type> - BOOST_BIND(boost::type, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) -{ - typedef typename _bi::list_av_7::type list_type; - return _bi::bind_t(f, list_type(a1, a2, a3, a4, a5, a6, a7)); -} - -template - _bi::bind_t::type> - BOOST_BIND(boost::type, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) -{ - typedef typename _bi::list_av_8::type list_type; - return _bi::bind_t(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8)); -} - -template - _bi::bind_t::type> - BOOST_BIND(boost::type, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) -{ - typedef typename _bi::list_av_9::type list_type; - return _bi::bind_t(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9)); -} - -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) - -// adaptable function objects - -template - _bi::bind_t<_bi::unspecified, F, _bi::list0> - BOOST_BIND(F f) -{ - typedef _bi::list0 list_type; - return _bi::bind_t<_bi::unspecified, F, list_type> (f, list_type()); -} - -template - _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_1::type> - BOOST_BIND(F f, A1 a1) -{ - typedef typename _bi::list_av_1::type list_type; - return _bi::bind_t<_bi::unspecified, F, list_type> (f, list_type(a1)); -} - -template - _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_2::type> - BOOST_BIND(F f, A1 a1, A2 a2) -{ - typedef typename _bi::list_av_2::type list_type; - return _bi::bind_t<_bi::unspecified, F, list_type> (f, list_type(a1, a2)); -} - -template - _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_3::type> - BOOST_BIND(F f, A1 a1, A2 a2, A3 a3) -{ - typedef typename _bi::list_av_3::type list_type; - return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3)); -} - -template - _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_4::type> - BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4) -{ - typedef typename _bi::list_av_4::type list_type; - return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4)); -} - -template - _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_5::type> - BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) -{ - typedef typename _bi::list_av_5::type list_type; - return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5)); -} - -template - _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_6::type> - BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) -{ - typedef typename _bi::list_av_6::type list_type; - return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6)); -} - -template - _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_7::type> - BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) -{ - typedef typename _bi::list_av_7::type list_type; - return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7)); -} - -template - _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_8::type> - BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) -{ - typedef typename _bi::list_av_8::type list_type; - return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8)); -} - -template - _bi::bind_t<_bi::unspecified, F, typename _bi::list_av_9::type> - BOOST_BIND(F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) -{ - typedef typename _bi::list_av_9::type list_type; - return _bi::bind_t<_bi::unspecified, F, list_type>(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9)); -} - -#endif // !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) - -// function pointers - -#define BOOST_BIND_CC -#define BOOST_BIND_ST - -#include - -#undef BOOST_BIND_CC -#undef BOOST_BIND_ST - -#ifdef BOOST_BIND_ENABLE_STDCALL - -#define BOOST_BIND_CC __stdcall -#define BOOST_BIND_ST - -#include - -#undef BOOST_BIND_CC -#undef BOOST_BIND_ST - -#endif - -#ifdef BOOST_BIND_ENABLE_FASTCALL - -#define BOOST_BIND_CC __fastcall -#define BOOST_BIND_ST - -#include - -#undef BOOST_BIND_CC -#undef BOOST_BIND_ST - -#endif - -#ifdef BOOST_BIND_ENABLE_PASCAL - -#define BOOST_BIND_ST pascal -#define BOOST_BIND_CC - -#include - -#undef BOOST_BIND_ST -#undef BOOST_BIND_CC - -#endif - -// member function pointers - -#define BOOST_BIND_MF_NAME(X) X -#define BOOST_BIND_MF_CC - -#include -#include - -#undef BOOST_BIND_MF_NAME -#undef BOOST_BIND_MF_CC - -#ifdef BOOST_MEM_FN_ENABLE_CDECL - -#define BOOST_BIND_MF_NAME(X) X##_cdecl -#define BOOST_BIND_MF_CC __cdecl - -#include -#include - -#undef BOOST_BIND_MF_NAME -#undef BOOST_BIND_MF_CC - -#endif - -#ifdef BOOST_MEM_FN_ENABLE_STDCALL - -#define BOOST_BIND_MF_NAME(X) X##_stdcall -#define BOOST_BIND_MF_CC __stdcall - -#include -#include - -#undef BOOST_BIND_MF_NAME -#undef BOOST_BIND_MF_CC - -#endif - -#ifdef BOOST_MEM_FN_ENABLE_FASTCALL - -#define BOOST_BIND_MF_NAME(X) X##_fastcall -#define BOOST_BIND_MF_CC __fastcall - -#include -#include - -#undef BOOST_BIND_MF_NAME -#undef BOOST_BIND_MF_CC - -#endif - -// data member pointers - -#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \ - || ( defined(__BORLANDC__) && BOOST_WORKAROUND( __BORLANDC__, < 0x600 ) ) - -template -_bi::bind_t< R, _mfi::dm, typename _bi::list_av_1::type > - BOOST_BIND(R T::*f, A1 a1) -{ - typedef _mfi::dm F; - typedef typename _bi::list_av_1::type list_type; - return _bi::bind_t( F(f), list_type(a1) ); -} - -#else - -namespace _bi -{ - -template< class Pm, int I > struct add_cref; - -template< class M, class T > struct add_cref< M T::*, 0 > -{ - typedef M type; -}; - -template< class M, class T > struct add_cref< M T::*, 1 > -{ - typedef M const & type; -}; - -template< class R, class T > struct add_cref< R (T::*) (), 1 > -{ - typedef void type; -}; - -#if !( defined(__IBMCPP__) && BOOST_WORKAROUND( __IBMCPP__, BOOST_TESTED_AT(600) ) ) - -template< class R, class T > struct add_cref< R (T::*) () const, 1 > -{ - typedef void type; -}; - -#endif // __IBMCPP__ - -template struct isref -{ - enum value_type { value = 0 }; -}; - -template struct isref< R& > -{ - enum value_type { value = 1 }; -}; - -template struct isref< R* > -{ - enum value_type { value = 1 }; -}; - -template struct dm_result -{ - typedef typename add_cref< Pm, 1 >::type type; -}; - -template struct dm_result< Pm, bind_t > -{ - typedef typename bind_t::result_type result_type; - typedef typename add_cref< Pm, isref< result_type >::value >::type type; -}; - -} // namespace _bi - -template< class A1, class M, class T > - -_bi::bind_t< - typename _bi::dm_result< M T::*, A1 >::type, - _mfi::dm, - typename _bi::list_av_1::type -> - -BOOST_BIND( M T::*f, A1 a1 ) -{ - typedef typename _bi::dm_result< M T::*, A1 >::type result_type; - typedef _mfi::dm F; - typedef typename _bi::list_av_1::type list_type; - return _bi::bind_t< result_type, F, list_type >( F( f ), list_type( a1 ) ); -} - -#endif - -} // namespace boost - -#ifndef BOOST_BIND_NO_PLACEHOLDERS - -# include - -#endif - -#ifdef BOOST_MSVC -# pragma warning(default: 4512) // assignment operator could not be generated -# pragma warning(pop) -#endif +#include #endif // #ifndef BOOST_BIND_HPP_INCLUDED diff --git a/include/boost/bind/bind.hpp b/include/boost/bind/bind.hpp index 07b84d3..7eb1dd2 100644 --- a/include/boost/bind/bind.hpp +++ b/include/boost/bind/bind.hpp @@ -1,5 +1,5 @@ -#ifndef BOOST_BIND_HPP_INCLUDED -#define BOOST_BIND_HPP_INCLUDED +#ifndef BOOST_BIND_BIND_HPP_INCLUDED +#define BOOST_BIND_BIND_HPP_INCLUDED // MS compatible compilers support #pragma once @@ -1716,4 +1716,4 @@ BOOST_BIND( M T::*f, A1 a1 ) # pragma warning(pop) #endif -#endif // #ifndef BOOST_BIND_HPP_INCLUDED +#endif // #ifndef BOOST_BIND_BIND_HPP_INCLUDED diff --git a/include/boost/bind/mem_fn.hpp b/include/boost/bind/mem_fn.hpp index 9695f57..956e7d8 100644 --- a/include/boost/bind/mem_fn.hpp +++ b/include/boost/bind/mem_fn.hpp @@ -1,5 +1,5 @@ -#ifndef BOOST_MEM_FN_HPP_INCLUDED -#define BOOST_MEM_FN_HPP_INCLUDED +#ifndef BOOST_BIND_MEM_FN_HPP_INCLUDED +#define BOOST_BIND_MEM_FN_HPP_INCLUDED // MS compatible compilers support #pragma once @@ -386,4 +386,4 @@ template _mfi::dm mem_fn(R T::*f) } // namespace boost -#endif // #ifndef BOOST_MEM_FN_HPP_INCLUDED +#endif // #ifndef BOOST_BIND_MEM_FN_HPP_INCLUDED diff --git a/include/boost/mem_fn.hpp b/include/boost/mem_fn.hpp index 9695f57..3bcd2c5 100644 --- a/include/boost/mem_fn.hpp +++ b/include/boost/mem_fn.hpp @@ -10,380 +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) 2003-2005 Peter Dimov +// 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 -#include -#include - -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 struct mf -{ - -#define BOOST_MEM_FN_RETURN return - -#define BOOST_MEM_FN_NAME(X) inner_##X -#define BOOST_MEM_FN_CC - -#include - -#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 - -#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 - -#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 - -#undef BOOST_MEM_FN_CC -#undef BOOST_MEM_FN_NAME - -#endif - -#undef BOOST_MEM_FN_RETURN - -}; // struct mf - -template<> struct mf -{ - -#define BOOST_MEM_FN_RETURN - -#define BOOST_MEM_FN_NAME(X) inner_##X -#define BOOST_MEM_FN_CC - -#include - -#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 - -#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 - -#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 - -#undef BOOST_MEM_FN_CC -#undef BOOST_MEM_FN_NAME - -#endif - -#undef BOOST_MEM_FN_RETURN - -}; // struct mf - -#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 - -#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 - -#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 - -#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 - -#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 - -#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 - -#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 - -#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 - -#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 - -#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 - -#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 - -#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 - -#undef BOOST_MEM_FN_NAME -#undef BOOST_MEM_FN_CC - -#endif - -// data member support - -namespace _mfi -{ - -template class dm -{ -public: - - typedef R const & result_type; - typedef T const * argument_type; - -private: - - typedef R (T::*F); - F f_; - - template R const & call(U & u, T const *) const - { - return (u.*f_); - } - - template 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 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 _mfi::dm mem_fn(R T::*f) -{ - return _mfi::dm(f); -} - -} // namespace boost +#include #endif // #ifndef BOOST_MEM_FN_HPP_INCLUDED From 8ae9e8460d0180e65fe49cf9652bc5bfd5275715 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 1 Mar 2009 16:06:44 +0000 Subject: [PATCH 33/62] Borland 6.10 still needs the workaround; fails bind_dm_test without it. [SVN r51510] --- include/boost/bind/bind.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/bind/bind.hpp b/include/boost/bind/bind.hpp index 7eb1dd2..5ee13b7 100644 --- a/include/boost/bind/bind.hpp +++ b/include/boost/bind/bind.hpp @@ -1615,7 +1615,7 @@ template _bi::bind_t< R, _mfi::dm, typename _bi::list_av_1::type > From 010349ec9b476f27d0b0cf955a820c89e9aad221 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 1 Mar 2009 16:31:53 +0000 Subject: [PATCH 34/62] Refs #2127 (fixed in trunk). [SVN r51511] --- include/boost/bind/bind.hpp | 5 ++++ test/Jamfile.v2 | 1 + test/bind_eq2_test.cpp | 49 +++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 test/bind_eq2_test.cpp diff --git a/include/boost/bind/bind.hpp b/include/boost/bind/bind.hpp index 5ee13b7..9510ffb 100644 --- a/include/boost/bind/bind.hpp +++ b/include/boost/bind/bind.hpp @@ -100,6 +100,11 @@ template bool ref_compare( reference_wrapper const & a, reference_wr template class bind_t; +template bool ref_compare( bind_t const & a, bind_t const & b, int ) +{ + return a.compare( b ); +} + // value template class value diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 38fb264..a0e0d07 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -38,4 +38,5 @@ test-suite "bind" [ run bind_fnobj2_test.cpp ] [ run bind_fn2_test.cpp ] [ run bind_mf2_test.cpp ] + [ run bind_eq2_test.cpp ] ; diff --git a/test/bind_eq2_test.cpp b/test/bind_eq2_test.cpp new file mode 100644 index 0000000..3d7ca38 --- /dev/null +++ b/test/bind_eq2_test.cpp @@ -0,0 +1,49 @@ +#include + +#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 +#include +#include + +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(); +} From bc50ab0ba31e3d3ac34f11c46404b990a51c7e2a Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 1 Mar 2009 17:04:14 +0000 Subject: [PATCH 35/62] Refs #2128 (fixed in trunk.) [SVN r51512] --- test/Jamfile.v2 | 2 ++ test/bind_ref_test.cpp | 36 ++++++++++++++++++++++++++++++++++++ test/mem_fn_ref_test.cpp | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 test/bind_ref_test.cpp create mode 100644 test/mem_fn_ref_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index a0e0d07..3149749 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -39,4 +39,6 @@ test-suite "bind" [ 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 ] ; diff --git a/test/bind_ref_test.cpp b/test/bind_ref_test.cpp new file mode 100644 index 0000000..f08172e --- /dev/null +++ b/test/bind_ref_test.cpp @@ -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 +#include +#include + +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(); +} diff --git a/test/mem_fn_ref_test.cpp b/test/mem_fn_ref_test.cpp new file mode 100644 index 0000000..be98941 --- /dev/null +++ b/test/mem_fn_ref_test.cpp @@ -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 +#include +#include + +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(); +} From 45a1f1434b55ca31bfef09be2ede9435e584d4e8 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 26 Mar 2009 00:43:14 +0000 Subject: [PATCH 36/62] Add ref_compare for weak_ptr. Refs #2849. [SVN r51979] --- include/boost/bind/bind.hpp | 9 ++++++++ test/Jamfile.v2 | 1 + test/bind_eq3_test.cpp | 45 +++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 test/bind_eq3_test.cpp diff --git a/include/boost/bind/bind.hpp b/include/boost/bind/bind.hpp index 9510ffb..1e5c9e0 100644 --- a/include/boost/bind/bind.hpp +++ b/include/boost/bind/bind.hpp @@ -48,6 +48,8 @@ namespace boost { +template class weak_ptr; + namespace _bi // implementation details { @@ -126,6 +128,13 @@ private: T t_; }; +// ref_compare for weak_ptr + +template bool ref_compare( value< weak_ptr > const & a, value< weak_ptr > const & b, int ) +{ + return !(a.get() < b.get()) && !(b.get() < a.get()); +} + // type template class type {}; diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 3149749..ea85a0b 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -41,4 +41,5 @@ test-suite "bind" [ run bind_eq2_test.cpp ] [ run mem_fn_ref_test.cpp ] [ run bind_ref_test.cpp ] + [ run bind_eq3_test.cpp ] ; diff --git a/test/bind_eq3_test.cpp b/test/bind_eq3_test.cpp new file mode 100644 index 0000000..03a5593 --- /dev/null +++ b/test/bind_eq3_test.cpp @@ -0,0 +1,45 @@ +#include + +#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 +#include +#include +#include + +int f( boost::weak_ptr 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() ) ); + + return boost::report_errors(); +} From dc1e4dbfae0921cea61c5d644ba137e02cc5dfc8 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Tue, 14 Apr 2009 13:45:59 +0000 Subject: [PATCH 37/62] Use static boost::arg placeholders for gcc 4.0.1, since it has a bug that prevents forwarding placeholders as const references when using the static inline function placeholders. [SVN r52384] --- include/boost/bind/placeholders.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/boost/bind/placeholders.hpp b/include/boost/bind/placeholders.hpp index 43baee6..37d01db 100644 --- a/include/boost/bind/placeholders.hpp +++ b/include/boost/bind/placeholders.hpp @@ -25,7 +25,7 @@ namespace { -#if defined(__BORLANDC__) || defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ <= 400) +#if defined(__BORLANDC__) || defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 400) 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__ * 100 + __GNUC_MINOR__ == 400) static boost::arg<1> _1; static boost::arg<2> _2; From 26ee2825fe9501281e536934c6a6ffffad3483b5 Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Fri, 26 Jun 2009 22:31:15 +0000 Subject: [PATCH 38/62] Make protect use the same approximation of perfect forwarding as plain bind. [SVN r54385] --- include/boost/bind/protect.hpp | 160 +++++++++++++++++++ test/Jamfile.v2 | 1 + test/protect_test.cpp | 281 +++++++++++++++++++++++++++++++++ 3 files changed, 442 insertions(+) create mode 100644 test/protect_test.cpp diff --git a/include/boost/bind/protect.hpp b/include/boost/bind/protect.hpp index b1ff2a2..749e158 100644 --- a/include/boost/bind/protect.hpp +++ b/include/boost/bind/protect.hpp @@ -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 +#include + namespace boost { @@ -47,6 +51,22 @@ public: return f_(a1); } + +#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \ + && !BOOST_WORKAROUND(__EDG_VERSION__, <= 238) + + template result_type operator()(const A1 & a1) + { + return f_(a1); + } + + template result_type operator()(const A1 & a1) const + { + return f_(a1); + } + +#endif + template 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 result_type operator()(A1 const & a1, A2 & a2) + { + return f_(a1, a2); + } + + template result_type operator()(A1 const & a1, A2 & a2) const + { + return f_(a1, a2); + } + + template result_type operator()(A1 & a1, A2 const & a2) + { + return f_(a1, a2); + } + + template result_type operator()(A1 & a1, A2 const & a2) const + { + return f_(a1, a2); + } + + template result_type operator()(A1 const & a1, A2 const & a2) + { + return f_(a1, a2); + } + + template result_type operator()(A1 const & a1, A2 const & a2) const + { + return f_(a1, a2); + } + +#endif + template 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 result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3) + { + return f_(a1, a2, a3); + } + + template result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3) const + { + return f_(a1, a2, a3); + } + +#endif template 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 result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4) + { + return f_(a1, a2, a3, a4); + } + + template result_type operator()(A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4) const + { + return f_(a1, a2, a3, a4); + } + +#endif template 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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: diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index ea85a0b..cecc7f7 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -42,4 +42,5 @@ test-suite "bind" [ run mem_fn_ref_test.cpp ] [ run bind_ref_test.cpp ] [ run bind_eq3_test.cpp ] + [ run protect_test.cpp ] ; diff --git a/test/protect_test.cpp b/test/protect_test.cpp new file mode 100644 index 0000000..7ca46ea --- /dev/null +++ b/test/protect_test.cpp @@ -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 +#include + +#include + +int f(int x) +{ + return x; +} + +int& g(int& x) +{ + return x; +} + +template +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(); +} From 73fc778b61d8b6c3505f9a1cbb843717949d6f1d Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Sun, 26 Jul 2009 00:49:56 +0000 Subject: [PATCH 39/62] Copyrights on CMakeLists.txt to keep them from clogging up the inspect reports. This is essentially the same commit as r55095 on the release branch. [SVN r55159] --- CMakeLists.txt | 6 ++++++ test/CMakeLists.txt | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f654c67..127ae27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,9 @@ +# +# Copyright Troy D. Straszheim +# +# Distributed under the Boost Software License, Version 1.0. +# See http://www.boost.org/LICENSE_1_0.txt +# #---------------------------------------------------------------------------- # This file was automatically generated from the original CMakeLists.txt file # Add a variable to hold the headers for the library diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7dd5a71..aff7ff5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,3 +1,9 @@ +# +# Copyright Troy D. Straszheim +# +# Distributed under the Boost Software License, Version 1.0. +# See http://www.boost.org/LICENSE_1_0.txt +# boost_additional_test_dependencies(bind BOOST_DEPENDS test) SET(tests From f3da835e0b6c5c4672076d189e85a93863ec9bc8 Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Sat, 17 Oct 2009 02:07:38 +0000 Subject: [PATCH 40/62] rm cmake from trunk. I'm not entirely sure this is necessary to satisfy the inspect script, but I'm not taking any chances, and it is easy to put back [SVN r56942] --- CMakeLists.txt | 28 ---------------------------- module.cmake | 1 - test/CMakeLists.txt | 36 ------------------------------------ 3 files changed, 65 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 module.cmake delete mode 100644 test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 127ae27..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# -# Copyright Troy D. Straszheim -# -# Distributed under the Boost Software License, Version 1.0. -# See http://www.boost.org/LICENSE_1_0.txt -# -#---------------------------------------------------------------------------- -# This file was automatically generated from the original CMakeLists.txt file -# Add a variable to hold the headers for the library -set (lib_headers - bind.hpp - bind -) - -# Add a library target to the build system -boost_library_project( - bind - # SRCDIRS - TESTDIRS test - HEADERS ${lib_headers} - # DOCDIRS - DESCRIPTION "A generalization of the standard functions std::bind1st and std::bind2nd. It supports arbitrary function objects, functions, function pointers, and member function pointers, and is able to bind any argument to a specific value or route input arguments into arbitrary positions." - MODULARIZED - AUTHORS "Peter Dimov " - # MAINTAINERS -) - - diff --git a/module.cmake b/module.cmake deleted file mode 100644 index beb4837..0000000 --- a/module.cmake +++ /dev/null @@ -1 +0,0 @@ -boost_module(bind DEPENDS utility mpl detail config) \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index aff7ff5..0000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -# -# Copyright Troy D. Straszheim -# -# Distributed under the Boost Software License, Version 1.0. -# See http://www.boost.org/LICENSE_1_0.txt -# -boost_additional_test_dependencies(bind BOOST_DEPENDS test) - -SET(tests - bind_test - bind_dm_test - bind_eq_test - bind_const_test - bind_cv_test - bind_stateful_test - bind_dm2_test - bind_not_test - bind_rel_test - bind_function_test - bind_lookup_problem_test - bind_rv_sp_test - bind_dm3_test - bind_visit_test - mem_fn_test - mem_fn_void_test - mem_fn_derived_test - mem_fn_eq_test - mem_fn_dm_test - mem_fn_rv_test - ) -FOREACH(test ${tests}) - boost_test_run(${test}) -ENDFOREACH(test ${tests}) - -boost_test_compile(bind_unary_addr) - From f02b090fe851ed2afa9617cddd862865f08a07d5 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Tue, 10 Nov 2009 13:26:43 +0000 Subject: [PATCH 41/62] Warning suppressions in Boost.Bind. Fixes #3601. [SVN r57542] --- include/boost/bind/bind.hpp | 18 ++++++++++++++++++ test/bind_visit_test.cpp | 1 + 2 files changed, 19 insertions(+) diff --git a/include/boost/bind/bind.hpp b/include/boost/bind/bind.hpp index 1e5c9e0..4c8a1e9 100644 --- a/include/boost/bind/bind.hpp +++ b/include/boost/bind/bind.hpp @@ -207,6 +207,13 @@ public: } }; +#ifdef BOOST_MSVC +// MSVC is bright enough to realise that the parameter rhs +// in operator==may be unused for some template argument types: +#pragma warning(push) +#pragma warning(disable:4100) +#endif + template< class A1 > class list1: private storage1< A1 > { private: @@ -846,6 +853,10 @@ public: } }; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + // bind_t #ifndef BOOST_NO_VOID_RETURNS @@ -1654,7 +1665,14 @@ template< class M, class T > struct add_cref< M T::*, 0 > template< class M, class T > struct add_cref< M T::*, 1 > { +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4180) +#endif typedef M const & type; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif }; template< class R, class T > struct add_cref< R (T::*) (), 1 > diff --git a/test/bind_visit_test.cpp b/test/bind_visit_test.cpp index 5fd8e88..16299dd 100644 --- a/test/bind_visit_test.cpp +++ b/test/bind_visit_test.cpp @@ -5,6 +5,7 @@ # 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 From 17282c97c2e80bba252d7763914da2c5fa7414e5 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 26 Nov 2009 21:02:04 +0000 Subject: [PATCH 42/62] Extend Borland workaround to 6.2 and above. [SVN r57954] --- include/boost/bind/bind.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/bind/bind.hpp b/include/boost/bind/bind.hpp index 4c8a1e9..a63d2a0 100644 --- a/include/boost/bind/bind.hpp +++ b/include/boost/bind/bind.hpp @@ -1640,7 +1640,7 @@ template _bi::bind_t< R, _mfi::dm, typename _bi::list_av_1::type > From e5d99ce0855d1b238280fa6225b309c4b1bb15a3 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 1 Dec 2009 02:24:53 +0000 Subject: [PATCH 43/62] Make mem_fn work with overloaded unary operator&. Refs #3003. Sorry it took so long. [SVN r58073] --- include/boost/bind/mem_fn_template.hpp | 54 +++++----- test/Jamfile.v2 | 1 + test/mem_fn_unary_addr_test.cpp | 141 +++++++++++++++++++++++++ 3 files changed, 169 insertions(+), 27 deletions(-) create mode 100644 test/mem_fn_unary_addr_test.cpp diff --git a/include/boost/bind/mem_fn_template.hpp b/include/boost/bind/mem_fn_template.hpp index 1db0713..7f01c24 100644 --- a/include/boost/bind/mem_fn_template.hpp +++ b/include/boost/bind/mem_fn_template.hpp @@ -51,14 +51,14 @@ public: template R operator()(U & u) const { - BOOST_MEM_FN_RETURN call(u, &u); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 )); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template R operator()(U const & u) const { - BOOST_MEM_FN_RETURN call(u, &u); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 )); } #endif @@ -109,7 +109,7 @@ public: template R operator()(U const & u) const { - BOOST_MEM_FN_RETURN call(u, &u); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 )); } R operator()(T const & t) const @@ -164,14 +164,14 @@ public: template R operator()(U & u, A1 a1) const { - BOOST_MEM_FN_RETURN call(u, &u, a1); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template R operator()(U const & u, A1 a1) const { - BOOST_MEM_FN_RETURN call(u, &u, a1); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1); } #endif @@ -223,7 +223,7 @@ public: template R operator()(U const & u, A1 a1) const { - BOOST_MEM_FN_RETURN call(u, &u, a1); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1); } R operator()(T const & t, A1 a1) const @@ -276,14 +276,14 @@ public: template R operator()(U & u, A1 a1, A2 a2) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template R operator()(U const & u, A1 a1, A2 a2) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2); } #endif @@ -333,7 +333,7 @@ public: template R operator()(U const & u, A1 a1, A2 a2) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2); } R operator()(T const & t, A1 a1, A2 a2) const @@ -386,14 +386,14 @@ public: template R operator()(U & u, A1 a1, A2 a2, A3 a3) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2, a3); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template R operator()(U const & u, A1 a1, A2 a2, A3 a3) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2, a3); } #endif @@ -443,7 +443,7 @@ public: template R operator()(U const & u, A1 a1, A2 a2, A3 a3) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2, a3); } R operator()(T const & t, A1 a1, A2 a2, A3 a3) const @@ -496,14 +496,14 @@ public: template R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2, a3, a4); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template 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); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2, a3, a4); } #endif @@ -553,7 +553,7 @@ public: template 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); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2, a3, a4); } R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4) const @@ -606,14 +606,14 @@ public: template 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); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2, a3, a4, a5); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template 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); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2, a3, a4, a5); } #endif @@ -663,7 +663,7 @@ public: template 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); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2, a3, a4, a5); } R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const @@ -716,14 +716,14 @@ public: template 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); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2, a3, a4, a5, a6); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template 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); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2, a3, a4, a5, a6); } #endif @@ -773,7 +773,7 @@ public: template 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); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2, a3, a4, a5, a6); } R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const @@ -826,14 +826,14 @@ public: template 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); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2, a3, a4, a5, a6, a7); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template 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); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2, a3, a4, a5, a6, a7); } #endif @@ -883,7 +883,7 @@ public: template 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); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), 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 @@ -936,14 +936,14 @@ public: template 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); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2, a3, a4, a5, a6, a7, a8); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template 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); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2, a3, a4, a5, a6, a7, a8); } #endif @@ -998,7 +998,7 @@ public: template 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); + BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), 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 diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index cecc7f7..68dc83d 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -43,4 +43,5 @@ test-suite "bind" [ run bind_ref_test.cpp ] [ run bind_eq3_test.cpp ] [ run protect_test.cpp ] + [ run mem_fn_unary_addr_test.cpp ] ; diff --git a/test/mem_fn_unary_addr_test.cpp b/test/mem_fn_unary_addr_test.cpp new file mode 100644 index 0000000..cb5da8b --- /dev/null +++ b/test/mem_fn_unary_addr_test.cpp @@ -0,0 +1,141 @@ +#include + +#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 + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include + +#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 Y +{ +private: + + T * pt_; + + void operator& (); + void operator& () const; + +public: + + explicit Y( T * pt ): pt_( pt ) + { + } + + T * get() const + { + return pt_; + } +}; + +template T * get_pointer( Y< T > const & y ) +{ + return y.get(); +} + +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 px( &x ); + Y 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 ); +} From 1bf8cd6c7aa923b2ce34886680ba43938188c07b Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 2 Dec 2009 10:47:01 +0000 Subject: [PATCH 44/62] Fix Borland regression. Refs #3003. [SVN r58093] --- include/boost/bind/mem_fn_template.hpp | 81 +++++++++++++++++--------- test/mem_fn_unary_addr_test.cpp | 10 ++++ 2 files changed, 64 insertions(+), 27 deletions(-) diff --git a/include/boost/bind/mem_fn_template.hpp b/include/boost/bind/mem_fn_template.hpp index 7f01c24..b26d585 100644 --- a/include/boost/bind/mem_fn_template.hpp +++ b/include/boost/bind/mem_fn_template.hpp @@ -51,14 +51,16 @@ public: template R operator()(U & u) const { - BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 )); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template R operator()(U const & u) const { - BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 )); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p); } #endif @@ -109,7 +111,8 @@ public: template R operator()(U const & u) const { - BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 )); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p); } R operator()(T const & t) const @@ -164,14 +167,16 @@ public: template R operator()(U & u, A1 a1) const { - BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template R operator()(U const & u, A1 a1) const { - BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1); } #endif @@ -223,7 +228,8 @@ public: template R operator()(U const & u, A1 a1) const { - BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1); } R operator()(T const & t, A1 a1) const @@ -276,14 +282,16 @@ public: template R operator()(U & u, A1 a1, A2 a2) const { - BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template R operator()(U const & u, A1 a1, A2 a2) const { - BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2); } #endif @@ -333,7 +341,8 @@ public: template R operator()(U const & u, A1 a1, A2 a2) const { - BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), 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 @@ -386,14 +395,16 @@ public: template R operator()(U & u, A1 a1, A2 a2, A3 a3) const { - BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), 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 R operator()(U const & u, A1 a1, A2 a2, A3 a3) const { - BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2, a3); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3); } #endif @@ -443,7 +454,8 @@ public: template R operator()(U const & u, A1 a1, A2 a2, A3 a3) const { - BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), 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 @@ -496,14 +508,16 @@ public: template R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4) const { - BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), 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 R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4) const { - BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2, a3, a4); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4); } #endif @@ -553,7 +567,8 @@ public: template R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4) const { - BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), 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 @@ -606,14 +621,16 @@ public: template R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const { - BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), 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 R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const { - BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2, a3, a4, a5); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5); } #endif @@ -663,7 +680,8 @@ public: template R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const { - BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), 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 @@ -716,14 +734,16 @@ public: template R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const { - BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), 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 R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const { - BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), a1, a2, a3, a4, a5, a6); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6); } #endif @@ -773,7 +793,8 @@ public: template R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const { - BOOST_MEM_FN_RETURN call(u, static_cast< U const * >( 0 ), 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 @@ -826,14 +847,16 @@ public: template 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, static_cast< U const * >( 0 ), 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 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, static_cast< U const * >( 0 ), 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); } #endif @@ -883,7 +906,8 @@ public: template 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, static_cast< U const * >( 0 ), 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 @@ -936,14 +960,16 @@ public: template 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, static_cast< U const * >( 0 ), 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 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, static_cast< U const * >( 0 ), 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); } #endif @@ -998,7 +1024,8 @@ public: template 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, static_cast< U const * >( 0 ), 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 diff --git a/test/mem_fn_unary_addr_test.cpp b/test/mem_fn_unary_addr_test.cpp index cb5da8b..61e9160 100644 --- a/test/mem_fn_unary_addr_test.cpp +++ b/test/mem_fn_unary_addr_test.cpp @@ -1,4 +1,5 @@ #include +#include #if defined(BOOST_MSVC) #pragma warning(disable: 4786) // identifier truncated in debug info @@ -82,11 +83,20 @@ public: } }; +#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x620 ) ) +namespace boost +{ +#endif + template 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 ) From 7aa58cf65364bd68b7811632f3470baa318b51e7 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 26 May 2010 19:34:10 +0000 Subject: [PATCH 45/62] Fix version check, as g++ 4.1 still has the PCH bug. Refs #4172. [SVN r62251] --- include/boost/bind/placeholders.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/bind/placeholders.hpp b/include/boost/bind/placeholders.hpp index 37d01db..3b098b1 100644 --- a/include/boost/bind/placeholders.hpp +++ b/include/boost/bind/placeholders.hpp @@ -25,7 +25,7 @@ namespace { -#if defined(__BORLANDC__) || defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 400) +#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>(); } @@ -38,7 +38,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__) || \ - defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ == 400) + defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ < 2) static boost::arg<1> _1; static boost::arg<2> _2; From f89c41dc7b5b4c7f38b45dc97771ab8468c6d79a Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 20 Jun 2010 18:00:48 +0000 Subject: [PATCH 46/62] Update various libraries' documentation build. Mostly to use the images and css files under doc/src instead of doc/html, usually be deleting the settings in order to use the defaults. Also add 'boost.root' to some builds in order to fix links which rely on it. [SVN r63146] --- doc/Jamfile.v2 | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index f59b823..978b370 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -9,5 +9,6 @@ import boostbook : boostbook ; boostbook ref-doc : ref.xml : pdf:boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html + boost.root=../../../.. ; From 3d60d74ff0a66b361436dd3f45ee9f7ab756559b Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Thu, 2 Dec 2010 13:17:09 +0000 Subject: [PATCH 47/62] Doc patch; refs #4532 [SVN r66973] --- bind.html | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/bind.html b/bind.html index 74110c5..b57d5df 100644 --- a/bind.html +++ b/bind.html @@ -61,6 +61,7 @@ bind<R>(f, ...)

    Binding a nonstandard function

    Binding an overloaded function

    +

    Modeling STL function object concepts

    const in signatures

    MSVC specific: using boost::bind;

    @@ -585,6 +586,48 @@ int main() boost::bind( get, _1 ); }
    +

    Modeling STL function object concepts

    +

    The function objects that are produced by boost::bind do not model the + STL Unary Function or + Binary Function concepts, + even when the function objects are unary or binary operations, because the function object + types are missing public typedefs result_type and argument_type or + first_argument_type and second_argument_type. In cases where these + typedefs are desirable, however, the utility function make_adaptable + can be used to adapt unary and binary function objects to these concepts. This allows + unary and binary function objects resulting from boost::bind to be combined with + STL templates such as std::unary_negate + and std::binary_negate.

    + +

    The make_adaptable function is defined in <boost/bind/make_adaptable.hpp>, + which must be included explicitly in addition to <boost/bind.hpp>:

    +
    +#include <boost/bind/make_adaptable.hpp>
    +
    +template <class R, class F> unspecified-type make_adaptable(F f);
    +
    +template<class R, class A1, class F> unspecified-unary-functional-type make_adaptable(F f);
    +
    +template<class R, class A1, class A2, class F> unspecified-binary-functional-type make_adaptable(F f);
    +
    +template<class R, class A1, class A2, class A3, class F> unspecified-ternary-functional-type make_adaptable(F f);
    +
    +template<class R, class A1, class A2, class A3, class A4, class F> unspecified-4-ary-functional-type make_adaptable(F f);
    +		
    + +

    This example shows how to use make_adaptable to make a predicate for "is not a space":

    +
    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) ) );
    +
    + +

    In this example, boost::bind creates the "is a space" (unary) predicate. + It is then passed to make_adaptable so that a function object modeling + the Unary Function concept can be created, serving as the argument to + std::not1.

    +

    const in signatures

    Some compilers, including MSVC 6.0 and Borland C++ 5.5.1, have problems with the top-level const in function signatures: From 27003baf129d86edfead0371d7f615070be51dd4 Mon Sep 17 00:00:00 2001 From: Bryce Adelstein-Lelbach Date: Fri, 14 Jan 2011 02:59:34 +0000 Subject: [PATCH 48/62] Pathscale-4.0 configuration code/workarounds. [SVN r68142] --- test/bind_cv_test.cpp | 6 ++++++ test/bind_stateful_test.cpp | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/test/bind_cv_test.cpp b/test/bind_cv_test.cpp index 55c2472..257aaa9 100644 --- a/test/bind_cv_test.cpp +++ b/test/bind_cv_test.cpp @@ -33,6 +33,12 @@ struct X { + // SGI-related compilers have odd compiler-synthesized ctors dtors + #ifdef __PATHSCALE__ + X() {} + ~X() {} + #endif + int operator()() { return 17041; diff --git a/test/bind_stateful_test.cpp b/test/bind_stateful_test.cpp index b57ea59..04fc0e8 100644 --- a/test/bind_stateful_test.cpp +++ b/test/bind_stateful_test.cpp @@ -43,6 +43,11 @@ public: { } + // SGI-related compilers have odd compiler-synthesized ctors and dtors + #ifdef __PATHSCALE__ + ~X() {} + #endif + int state() const { return state_; From da3580cc148ea1acf94289f3f0495c730177fcef Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 7 Nov 2011 18:25:33 +0000 Subject: [PATCH 49/62] Apply suggested IBM C++ fix. Refs #5792. [SVN r75391] --- include/boost/bind/bind.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/bind/bind.hpp b/include/boost/bind/bind.hpp index a63d2a0..fb67097 100644 --- a/include/boost/bind/bind.hpp +++ b/include/boost/bind/bind.hpp @@ -1680,7 +1680,7 @@ template< class R, class T > struct add_cref< R (T::*) (), 1 > typedef void type; }; -#if !( defined(__IBMCPP__) && BOOST_WORKAROUND( __IBMCPP__, BOOST_TESTED_AT(600) ) ) +#if !defined(__IBMCPP__) || __IBMCPP_FUNC_CV_TMPL_ARG_DEDUCTION template< class R, class T > struct add_cref< R (T::*) () const, 1 > { From 9955139c655a741015a74a146765acb3f8320a1a Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 26 Sep 2013 09:42:51 +0000 Subject: [PATCH 50/62] Bind: Remove obsolete MSVC version check [SVN r85938] --- include/boost/bind/mem_fn.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/bind/mem_fn.hpp b/include/boost/bind/mem_fn.hpp index 956e7d8..3b00f17 100644 --- a/include/boost/bind/mem_fn.hpp +++ b/include/boost/bind/mem_fn.hpp @@ -352,7 +352,7 @@ public: return call(u, &u); } -#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) && !BOOST_WORKAROUND(__MWERKS__, < 0x3200) +#if !BOOST_WORKAROUND(__MWERKS__, < 0x3200) R & operator()(T & t) const { From 5e2fc717f0ece59553f380aac14c545979558306 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 26 Sep 2013 13:02:51 +0000 Subject: [PATCH 51/62] Remove obsolete MSVC check from pragma guard git grep -h -B1 "^#\s*pragma once" | grep -v pragma | sort | uniq is now clean. [SVN r85952] --- include/boost/bind.hpp | 2 +- include/boost/bind/arg.hpp | 2 +- include/boost/bind/bind.hpp | 2 +- include/boost/bind/mem_fn.hpp | 2 +- include/boost/bind/placeholders.hpp | 2 +- include/boost/bind/storage.hpp | 2 +- include/boost/is_placeholder.hpp | 2 +- include/boost/mem_fn.hpp | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/boost/bind.hpp b/include/boost/bind.hpp index fd3421e..503fb4d 100644 --- a/include/boost/bind.hpp +++ b/include/boost/bind.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma once #endif diff --git a/include/boost/bind/arg.hpp b/include/boost/bind/arg.hpp index 0d5cd03..c1da4d0 100644 --- a/include/boost/bind/arg.hpp +++ b/include/boost/bind/arg.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma once #endif diff --git a/include/boost/bind/bind.hpp b/include/boost/bind/bind.hpp index fb67097..957974d 100644 --- a/include/boost/bind/bind.hpp +++ b/include/boost/bind/bind.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma once #endif diff --git a/include/boost/bind/mem_fn.hpp b/include/boost/bind/mem_fn.hpp index 3b00f17..faf9848 100644 --- a/include/boost/bind/mem_fn.hpp +++ b/include/boost/bind/mem_fn.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma once #endif diff --git a/include/boost/bind/placeholders.hpp b/include/boost/bind/placeholders.hpp index 3b098b1..97e7a68 100644 --- a/include/boost/bind/placeholders.hpp +++ b/include/boost/bind/placeholders.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma once #endif diff --git a/include/boost/bind/storage.hpp b/include/boost/bind/storage.hpp index be490b0..556f707 100644 --- a/include/boost/bind/storage.hpp +++ b/include/boost/bind/storage.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma once #endif diff --git a/include/boost/is_placeholder.hpp b/include/boost/is_placeholder.hpp index 5f1b544..fb746f2 100644 --- a/include/boost/is_placeholder.hpp +++ b/include/boost/is_placeholder.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined( _MSC_VER ) && ( _MSC_VER >= 1020 ) +#if defined(_MSC_VER) # pragma once #endif diff --git a/include/boost/mem_fn.hpp b/include/boost/mem_fn.hpp index 3bcd2c5..8932d4d 100644 --- a/include/boost/mem_fn.hpp +++ b/include/boost/mem_fn.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma once #endif From 5b2cf44de5d7e4d5b024c073a3089fffd8e67731 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 1 Oct 2013 08:42:35 +0000 Subject: [PATCH 52/62] Bind: Remove obsolete GCC version check. [SVN r86106] --- include/boost/bind/bind.hpp | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/include/boost/bind/bind.hpp b/include/boost/bind/bind.hpp index 957974d..7f45242 100644 --- a/include/boost/bind/bind.hpp +++ b/include/boost/bind/bind.hpp @@ -1211,27 +1211,6 @@ BOOST_BIND_OPERATOR( ||, logical_or ) #undef BOOST_BIND_OPERATOR -#if defined(__GNUC__) && BOOST_WORKAROUND(__GNUC__, < 3) - -// resolve ambiguity with rel_ops - -#define BOOST_BIND_OPERATOR( op, name ) \ -\ -template \ - bind_t< bool, name, list2< bind_t, bind_t > > \ - operator op (bind_t const & f, bind_t const & g) \ -{ \ - typedef list2< bind_t, bind_t > list_type; \ - return bind_t ( name(), list_type(f, g) ); \ -} - -BOOST_BIND_OPERATOR( !=, not_equal ) -BOOST_BIND_OPERATOR( <=, less_equal ) -BOOST_BIND_OPERATOR( >, greater ) -BOOST_BIND_OPERATOR( >=, greater_equal ) - -#endif - // visit_each, ADL #if !defined( BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP ) && !defined( __BORLANDC__ ) \ From af136e483d1290339045138421811f16d7e9d931 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 11 Oct 2013 23:15:00 +0000 Subject: [PATCH 53/62] Remove BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION Process #ifndef...#endif conditions. [SVN r86244] --- include/boost/bind/arg.hpp | 2 -- include/boost/bind/bind.hpp | 2 -- include/boost/bind/storage.hpp | 16 ---------------- 3 files changed, 20 deletions(-) diff --git a/include/boost/bind/arg.hpp b/include/boost/bind/arg.hpp index c1da4d0..797e2b7 100644 --- a/include/boost/bind/arg.hpp +++ b/include/boost/bind/arg.hpp @@ -43,7 +43,6 @@ template< int I > bool operator==( arg const &, arg const & ) return true; } -#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template< int I > struct is_placeholder< arg > { @@ -55,7 +54,6 @@ template< int I > struct is_placeholder< arg (*) () > enum _vt { value = I }; }; -#endif } // namespace boost diff --git a/include/boost/bind/bind.hpp b/include/boost/bind/bind.hpp index 7f45242..2b0a1fe 100644 --- a/include/boost/bind/bind.hpp +++ b/include/boost/bind/bind.hpp @@ -1255,14 +1255,12 @@ template< class T > struct is_bind_expression enum _vt { value = 0 }; }; -#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template< class R, class F, class L > struct is_bind_expression< _bi::bind_t< R, F, L > > { enum _vt { value = 1 }; }; -#endif // bind diff --git a/include/boost/bind/storage.hpp b/include/boost/bind/storage.hpp index 556f707..9891c8c 100644 --- a/include/boost/bind/storage.hpp +++ b/include/boost/bind/storage.hpp @@ -88,7 +88,6 @@ template struct storage2: public storage1 A2 a2_; }; -#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template struct storage2< A1, boost::arg >: public storage1 { @@ -118,7 +117,6 @@ template struct storage2< A1, boost::arg (*) () >: public st static boost::arg a2_() { return boost::arg(); } }; -#endif // 3 @@ -137,7 +135,6 @@ template struct storage3: public storage2< A1, A2 A3 a3_; }; -#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template struct storage3< A1, A2, boost::arg >: public storage2< A1, A2 > { @@ -167,7 +164,6 @@ template struct storage3< A1, A2, boost::arg (*) ( static boost::arg a3_() { return boost::arg(); } }; -#endif // 4 @@ -186,7 +182,6 @@ template struct storage4: public storage A4 a4_; }; -#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template struct storage4< A1, A2, A3, boost::arg >: public storage3< A1, A2, A3 > { @@ -216,7 +211,6 @@ template struct storage4< A1, A2, A3, boost static boost::arg a4_() { return boost::arg(); } }; -#endif // 5 @@ -235,7 +229,6 @@ template struct storage5: publ A5 a5_; }; -#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template struct storage5< A1, A2, A3, A4, boost::arg >: public storage4< A1, A2, A3, A4 > { @@ -265,7 +258,6 @@ template struct storage5< A1, A2, static boost::arg a5_() { return boost::arg(); } }; -#endif // 6 @@ -284,7 +276,6 @@ template struct stor A6 a6_; }; -#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template struct storage6< A1, A2, A3, A4, A5, boost::arg >: public storage5< A1, A2, A3, A4, A5 > { @@ -314,7 +305,6 @@ template struct storage static boost::arg a6_() { return boost::arg(); } }; -#endif // 7 @@ -333,7 +323,6 @@ template s A7 a7_; }; -#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template struct storage7< A1, A2, A3, A4, A5, A6, boost::arg >: public storage6< A1, A2, A3, A4, A5, A6 > { @@ -363,7 +352,6 @@ template stru static boost::arg a7_() { return boost::arg(); } }; -#endif // 8 @@ -382,7 +370,6 @@ template struct storage8< A1, A2, A3, A4, A5, A6, A7, boost::arg >: public storage7< A1, A2, A3, A4, A5, A6, A7 > { @@ -412,7 +399,6 @@ template a8_() { return boost::arg(); } }; -#endif // 9 @@ -431,7 +417,6 @@ template struct storage9< A1, A2, A3, A4, A5, A6, A7, A8, boost::arg >: public storage8< A1, A2, A3, A4, A5, A6, A7, A8 > { @@ -461,7 +446,6 @@ template a9_() { return boost::arg(); } }; -#endif } // namespace _bi From 0f66412487d4d4eaa7d5eed81a3376e804a6fa0a Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 11 Oct 2013 23:20:59 +0000 Subject: [PATCH 54/62] Simplify multi-component ifdefs containing BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION [SVN r86248] --- include/boost/bind/bind.hpp | 6 +++--- include/boost/bind/storage.hpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/bind/bind.hpp b/include/boost/bind/bind.hpp index 2b0a1fe..f1b94f5 100644 --- a/include/boost/bind/bind.hpp +++ b/include/boost/bind/bind.hpp @@ -60,7 +60,7 @@ template struct result_traits typedef R type; }; -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) +#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) struct unspecified {}; @@ -1432,7 +1432,7 @@ template(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9)); } -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) +#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) // adaptable function objects @@ -1516,7 +1516,7 @@ template(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9)); } -#endif // !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) +#endif // !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) // function pointers diff --git a/include/boost/bind/storage.hpp b/include/boost/bind/storage.hpp index 9891c8c..6a5a402 100644 --- a/include/boost/bind/storage.hpp +++ b/include/boost/bind/storage.hpp @@ -49,7 +49,7 @@ template struct storage1 A1 a1_; }; -#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) && !defined( __BORLANDC__ ) +#if !defined( __BORLANDC__ ) template struct storage1< boost::arg > { From 7ff6524bd106176db0f95c28fb7bae77c2dc2728 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 11 Oct 2013 23:22:36 +0000 Subject: [PATCH 55/62] Remove remaining occurances of BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION These evaded scripting. [SVN r86249] --- include/boost/bind/bind.hpp | 43 +------------------------------------ 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/include/boost/bind/bind.hpp b/include/boost/bind/bind.hpp index f1b94f5..626729e 100644 --- a/include/boost/bind/bind.hpp +++ b/include/boost/bind/bind.hpp @@ -980,8 +980,6 @@ namespace _bi // add_value -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || (__SUNPRO_CC >= 0x530) - #if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x582) ) template struct add_value @@ -1033,45 +1031,6 @@ template struct add_value< bind_t > typedef bind_t type; }; -#else - -template struct _avt_0; - -template<> struct _avt_0<1> -{ - template struct inner - { - typedef T type; - }; -}; - -template<> struct _avt_0<2> -{ - template struct inner - { - typedef value type; - }; -}; - -typedef char (&_avt_r1) [1]; -typedef char (&_avt_r2) [2]; - -template _avt_r1 _avt_f(value); -template _avt_r1 _avt_f(reference_wrapper); -template _avt_r1 _avt_f(arg); -template _avt_r1 _avt_f(arg (*) ()); -template _avt_r1 _avt_f(bind_t); - -_avt_r2 _avt_f(...); - -template struct add_value -{ - static T t(); - typedef typename _avt_0::template inner::type type; -}; - -#endif - // list_av_N template struct list_av_1 @@ -1616,7 +1575,7 @@ template From 96fd1e7036b6ec548504034c993c3cb6e015b143 Mon Sep 17 00:00:00 2001 From: Michel Morin Date: Wed, 30 Oct 2013 12:51:24 +0000 Subject: [PATCH 56/62] Correct broken links to C++ standard papers. Refs #9212. [SVN r86524] --- bind.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bind.html b/bind.html index b57d5df..d06d707 100644 --- a/bind.html +++ b/bind.html @@ -390,7 +390,7 @@ void connect()

    As a general rule, the function objects generated by bind 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 + current (2003) incarnation, known as the forwarding problem. (It will be fixed in the next standard, usually called C++0x.)

    The library uses signatures of the form From aa8a94273d69b950ffe930b3aecba2c249390235 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 7 Dec 2013 18:50:56 +0200 Subject: [PATCH 57/62] Revert "Remove remaining occurances of BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION" This reverts commit 7ff6524bd106176db0f95c28fb7bae77c2dc2728. --- include/boost/bind/bind.hpp | 43 ++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/include/boost/bind/bind.hpp b/include/boost/bind/bind.hpp index 626729e..f1b94f5 100644 --- a/include/boost/bind/bind.hpp +++ b/include/boost/bind/bind.hpp @@ -980,6 +980,8 @@ namespace _bi // add_value +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || (__SUNPRO_CC >= 0x530) + #if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x582) ) template struct add_value @@ -1031,6 +1033,45 @@ template struct add_value< bind_t > typedef bind_t type; }; +#else + +template struct _avt_0; + +template<> struct _avt_0<1> +{ + template struct inner + { + typedef T type; + }; +}; + +template<> struct _avt_0<2> +{ + template struct inner + { + typedef value type; + }; +}; + +typedef char (&_avt_r1) [1]; +typedef char (&_avt_r2) [2]; + +template _avt_r1 _avt_f(value); +template _avt_r1 _avt_f(reference_wrapper); +template _avt_r1 _avt_f(arg); +template _avt_r1 _avt_f(arg (*) ()); +template _avt_r1 _avt_f(bind_t); + +_avt_r2 _avt_f(...); + +template struct add_value +{ + static T t(); + typedef typename _avt_0::template inner::type type; +}; + +#endif + // list_av_N template struct list_av_1 @@ -1575,7 +1616,7 @@ template From ce0fc0f69a2486dcaee7503dc20de576544ce873 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 7 Dec 2013 18:51:53 +0200 Subject: [PATCH 58/62] Revert "Simplify multi-component ifdefs containing BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION" This reverts commit 0f66412487d4d4eaa7d5eed81a3376e804a6fa0a. --- include/boost/bind/bind.hpp | 6 +++--- include/boost/bind/storage.hpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/bind/bind.hpp b/include/boost/bind/bind.hpp index f1b94f5..2b0a1fe 100644 --- a/include/boost/bind/bind.hpp +++ b/include/boost/bind/bind.hpp @@ -60,7 +60,7 @@ template struct result_traits typedef R type; }; -#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) struct unspecified {}; @@ -1432,7 +1432,7 @@ template(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9)); } -#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) // adaptable function objects @@ -1516,7 +1516,7 @@ template(f, list_type(a1, a2, a3, a4, a5, a6, a7, a8, a9)); } -#endif // !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) +#endif // !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) // function pointers diff --git a/include/boost/bind/storage.hpp b/include/boost/bind/storage.hpp index 6a5a402..9891c8c 100644 --- a/include/boost/bind/storage.hpp +++ b/include/boost/bind/storage.hpp @@ -49,7 +49,7 @@ template struct storage1 A1 a1_; }; -#if !defined( __BORLANDC__ ) +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) && !defined( __BORLANDC__ ) template struct storage1< boost::arg > { From f5c95610b6238d5102fecc37e0140a9caebc26da Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 7 Dec 2013 18:52:39 +0200 Subject: [PATCH 59/62] Revert "Remove BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION" This reverts commit af136e483d1290339045138421811f16d7e9d931. --- include/boost/bind/arg.hpp | 2 ++ include/boost/bind/bind.hpp | 2 ++ include/boost/bind/storage.hpp | 16 ++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/include/boost/bind/arg.hpp b/include/boost/bind/arg.hpp index 797e2b7..c1da4d0 100644 --- a/include/boost/bind/arg.hpp +++ b/include/boost/bind/arg.hpp @@ -43,6 +43,7 @@ template< int I > bool operator==( arg const &, arg const & ) return true; } +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template< int I > struct is_placeholder< arg > { @@ -54,6 +55,7 @@ template< int I > struct is_placeholder< arg (*) () > enum _vt { value = I }; }; +#endif } // namespace boost diff --git a/include/boost/bind/bind.hpp b/include/boost/bind/bind.hpp index 2b0a1fe..7f45242 100644 --- a/include/boost/bind/bind.hpp +++ b/include/boost/bind/bind.hpp @@ -1255,12 +1255,14 @@ template< class T > struct is_bind_expression enum _vt { value = 0 }; }; +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template< class R, class F, class L > struct is_bind_expression< _bi::bind_t< R, F, L > > { enum _vt { value = 1 }; }; +#endif // bind diff --git a/include/boost/bind/storage.hpp b/include/boost/bind/storage.hpp index 9891c8c..556f707 100644 --- a/include/boost/bind/storage.hpp +++ b/include/boost/bind/storage.hpp @@ -88,6 +88,7 @@ template struct storage2: public storage1 A2 a2_; }; +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template struct storage2< A1, boost::arg >: public storage1 { @@ -117,6 +118,7 @@ template struct storage2< A1, boost::arg (*) () >: public st static boost::arg a2_() { return boost::arg(); } }; +#endif // 3 @@ -135,6 +137,7 @@ template struct storage3: public storage2< A1, A2 A3 a3_; }; +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template struct storage3< A1, A2, boost::arg >: public storage2< A1, A2 > { @@ -164,6 +167,7 @@ template struct storage3< A1, A2, boost::arg (*) ( static boost::arg a3_() { return boost::arg(); } }; +#endif // 4 @@ -182,6 +186,7 @@ template struct storage4: public storage A4 a4_; }; +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template struct storage4< A1, A2, A3, boost::arg >: public storage3< A1, A2, A3 > { @@ -211,6 +216,7 @@ template struct storage4< A1, A2, A3, boost static boost::arg a4_() { return boost::arg(); } }; +#endif // 5 @@ -229,6 +235,7 @@ template struct storage5: publ A5 a5_; }; +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template struct storage5< A1, A2, A3, A4, boost::arg >: public storage4< A1, A2, A3, A4 > { @@ -258,6 +265,7 @@ template struct storage5< A1, A2, static boost::arg a5_() { return boost::arg(); } }; +#endif // 6 @@ -276,6 +284,7 @@ template struct stor A6 a6_; }; +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template struct storage6< A1, A2, A3, A4, A5, boost::arg >: public storage5< A1, A2, A3, A4, A5 > { @@ -305,6 +314,7 @@ template struct storage static boost::arg a6_() { return boost::arg(); } }; +#endif // 7 @@ -323,6 +333,7 @@ template s A7 a7_; }; +#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template struct storage7< A1, A2, A3, A4, A5, A6, boost::arg >: public storage6< A1, A2, A3, A4, A5, A6 > { @@ -352,6 +363,7 @@ template stru static boost::arg a7_() { return boost::arg(); } }; +#endif // 8 @@ -370,6 +382,7 @@ template struct storage8< A1, A2, A3, A4, A5, A6, A7, boost::arg >: public storage7< A1, A2, A3, A4, A5, A6, A7 > { @@ -399,6 +412,7 @@ template a8_() { return boost::arg(); } }; +#endif // 9 @@ -417,6 +431,7 @@ template struct storage9< A1, A2, A3, A4, A5, A6, A7, A8, boost::arg >: public storage8< A1, A2, A3, A4, A5, A6, A7, A8 > { @@ -446,6 +461,7 @@ template a9_() { return boost::arg(); } }; +#endif } // namespace _bi From ba117db120ec53a94330ce349ce4c1f9bf5de1eb Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 7 Dec 2013 18:53:01 +0200 Subject: [PATCH 60/62] Revert "Bind: Remove obsolete GCC version check." This reverts commit 5b2cf44de5d7e4d5b024c073a3089fffd8e67731. --- include/boost/bind/bind.hpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/boost/bind/bind.hpp b/include/boost/bind/bind.hpp index 7f45242..957974d 100644 --- a/include/boost/bind/bind.hpp +++ b/include/boost/bind/bind.hpp @@ -1211,6 +1211,27 @@ BOOST_BIND_OPERATOR( ||, logical_or ) #undef BOOST_BIND_OPERATOR +#if defined(__GNUC__) && BOOST_WORKAROUND(__GNUC__, < 3) + +// resolve ambiguity with rel_ops + +#define BOOST_BIND_OPERATOR( op, name ) \ +\ +template \ + bind_t< bool, name, list2< bind_t, bind_t > > \ + operator op (bind_t const & f, bind_t const & g) \ +{ \ + typedef list2< bind_t, bind_t > list_type; \ + return bind_t ( name(), list_type(f, g) ); \ +} + +BOOST_BIND_OPERATOR( !=, not_equal ) +BOOST_BIND_OPERATOR( <=, less_equal ) +BOOST_BIND_OPERATOR( >, greater ) +BOOST_BIND_OPERATOR( >=, greater_equal ) + +#endif + // visit_each, ADL #if !defined( BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP ) && !defined( __BORLANDC__ ) \ From 15d6d6ac95c06dfe5c3a0176c9f37b7425a266d8 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 7 Dec 2013 18:53:27 +0200 Subject: [PATCH 61/62] Revert "Remove obsolete MSVC check from pragma guard" This reverts commit 5e2fc717f0ece59553f380aac14c545979558306. --- include/boost/bind.hpp | 2 +- include/boost/bind/arg.hpp | 2 +- include/boost/bind/bind.hpp | 2 +- include/boost/bind/mem_fn.hpp | 2 +- include/boost/bind/placeholders.hpp | 2 +- include/boost/bind/storage.hpp | 2 +- include/boost/is_placeholder.hpp | 2 +- include/boost/mem_fn.hpp | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/boost/bind.hpp b/include/boost/bind.hpp index 503fb4d..fd3421e 100644 --- a/include/boost/bind.hpp +++ b/include/boost/bind.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif diff --git a/include/boost/bind/arg.hpp b/include/boost/bind/arg.hpp index c1da4d0..0d5cd03 100644 --- a/include/boost/bind/arg.hpp +++ b/include/boost/bind/arg.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif diff --git a/include/boost/bind/bind.hpp b/include/boost/bind/bind.hpp index 957974d..fb67097 100644 --- a/include/boost/bind/bind.hpp +++ b/include/boost/bind/bind.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif diff --git a/include/boost/bind/mem_fn.hpp b/include/boost/bind/mem_fn.hpp index faf9848..3b00f17 100644 --- a/include/boost/bind/mem_fn.hpp +++ b/include/boost/bind/mem_fn.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif diff --git a/include/boost/bind/placeholders.hpp b/include/boost/bind/placeholders.hpp index 97e7a68..3b098b1 100644 --- a/include/boost/bind/placeholders.hpp +++ b/include/boost/bind/placeholders.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif diff --git a/include/boost/bind/storage.hpp b/include/boost/bind/storage.hpp index 556f707..be490b0 100644 --- a/include/boost/bind/storage.hpp +++ b/include/boost/bind/storage.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif diff --git a/include/boost/is_placeholder.hpp b/include/boost/is_placeholder.hpp index fb746f2..5f1b544 100644 --- a/include/boost/is_placeholder.hpp +++ b/include/boost/is_placeholder.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) +#if defined( _MSC_VER ) && ( _MSC_VER >= 1020 ) # pragma once #endif diff --git a/include/boost/mem_fn.hpp b/include/boost/mem_fn.hpp index 8932d4d..3bcd2c5 100644 --- a/include/boost/mem_fn.hpp +++ b/include/boost/mem_fn.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif From 8414233b9cfcb0f3cd2667cddd56cab35e04b599 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 7 Dec 2013 18:54:00 +0200 Subject: [PATCH 62/62] Revert "Bind: Remove obsolete MSVC version check" This reverts commit 9955139c655a741015a74a146765acb3f8320a1a. --- include/boost/bind/mem_fn.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/bind/mem_fn.hpp b/include/boost/bind/mem_fn.hpp index 3b00f17..956e7d8 100644 --- a/include/boost/bind/mem_fn.hpp +++ b/include/boost/bind/mem_fn.hpp @@ -352,7 +352,7 @@ public: return call(u, &u); } -#if !BOOST_WORKAROUND(__MWERKS__, < 0x3200) +#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) && !BOOST_WORKAROUND(__MWERKS__, < 0x3200) R & operator()(T & t) const {