From 472f9e6ebed90be06b85aa4c806a1a4849c87eca Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 21 Mar 2006 02:26:31 +0000 Subject: [PATCH 01/34] This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'. [SVN r33417] --- mem_fn.html | 412 +--------------------------------------------------- 1 file changed, 7 insertions(+), 405 deletions(-) diff --git a/mem_fn.html b/mem_fn.html index 5cc89f2..39a8f41 100644 --- a/mem_fn.html +++ b/mem_fn.html @@ -1,407 +1,9 @@ - - - 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. + From a87638486bda4bac1234753ef5930725eb3c31b4 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 27 Apr 2006 16:21:01 +0000 Subject: [PATCH 02/34] Fixed a visit_each-related bug exposed by strict two-phase lookup [SVN r33841] --- include/boost/bind.hpp | 31 +++++++++++++++++++++++----- include/boost/bind/bind_template.hpp | 5 +++++ test/bind_visit_test.cpp | 5 ++++- 3 files changed, 35 insertions(+), 6 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); } 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 e8646fa2606a432fefc20fdfa7dd797cb1e9836a Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 20 Sep 2006 13:07:20 +0000 Subject: [PATCH 03/34] 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 bece8a7..6979fec 100644 --- a/include/boost/bind.hpp +++ b/include/boost/bind.hpp @@ -1161,7 +1161,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 ) { @@ -1180,7 +1181,8 @@ template void visit_each( V & v, bind_t void visit_each( V & v, _bi::value const & t, int ) { From c5396f02c68785605a876a616c2a11b25bcd4d7a Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Mon, 6 Nov 2006 17:10:46 +0000 Subject: [PATCH 04/34] Remove obsolete Boost.Build v1 files. [SVN r35880] --- test/Jamfile | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 test/Jamfile diff --git a/test/Jamfile b/test/Jamfile deleted file mode 100644 index 9cb627c..0000000 --- a/test/Jamfile +++ /dev/null @@ -1,42 +0,0 @@ -# Boost.Bind Library test Jamfile -# -# 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. - -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 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 967e9af0eb4654ea78073684f598e654a08cd016 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Tue, 7 Nov 2006 19:27:00 +0000 Subject: [PATCH 05/34] Merged copyright and license addition [SVN r35907] --- index.html | 8 ++++++-- mem_fn.html | 9 +++++++-- 2 files changed, 13 insertions(+), 4 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 39a8f41..f04a667 100644 --- a/mem_fn.html +++ b/mem_fn.html @@ -4,6 +4,11 @@ Automatic redirection failed, please go to -../bind/mem_fn.html. +../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 4d1f7d04113bd861aa786e4319a23cbdc1520db9 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 9 Nov 2006 19:36:51 +0000 Subject: [PATCH 06/34] License/copyright edits [SVN r35955] --- bind.html | 7 +- index.html | 14 +- mem_fn.html | 418 ++++++++++++++++++++++++++++++++++++++++++++++-- ref.html | 6 + test/Jamfile.v2 | 7 +- 5 files changed, 425 insertions(+), 27 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.v2 b/test/Jamfile.v2 index 170166b..f8b7813 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 9ea5cf40dab293841744b97f4423db4341af7556 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 10 Nov 2006 18:27:05 +0000 Subject: [PATCH 07/34] 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 41a2e801978634c5407a00dfdf17a047dbd27c34 Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 24 Jul 2007 19:28:14 +0000 Subject: [PATCH 08/34] This commit was manufactured by cvs2svn to create tag 'Version_1_34_1'. [SVN r38286] From 77d2c4bab1e19889ba96e796296c058191402682 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Fri, 5 Oct 2007 14:25:06 +0000 Subject: [PATCH 09/34] Starting point for releases [SVN r39706] --- mem_fn.html | 418 ++-------------------------------------------------- 1 file changed, 13 insertions(+), 405 deletions(-) diff --git a/mem_fn.html b/mem_fn.html index 1ec8f1e..f04a667 100644 --- a/mem_fn.html +++ b/mem_fn.html @@ -1,406 +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. 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.

- - + + + + +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 1943ac521be5db9ac5db1998e8f927fa10edfe49 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Sun, 25 Nov 2007 18:07:19 +0000 Subject: [PATCH 10/34] Full merge from trunk at revision 41356 of entire boost-root tree. [SVN r41369] --- include/boost/bind.hpp | 38 +++++++++ include/boost/bind/arg.hpp | 30 ++++++- include/boost/bind/bind_template.hpp | 119 +++++++++++++++++++++++++++ include/boost/bind/placeholders.hpp | 2 +- include/boost/is_placeholder.hpp | 31 +++++++ 5 files changed, 217 insertions(+), 3 deletions(-) create mode 100644 include/boost/is_placeholder.hpp diff --git a/include/boost/bind.hpp b/include/boost/bind.hpp index 6979fec..e1076e0 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 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; @@ -1196,6 +1218,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/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/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>(); } 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 From 224e9f5eecac2a41c858728fe724b7152871b032 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Sun, 25 Nov 2007 18:38:02 +0000 Subject: [PATCH 11/34] Full merge from trunk at revision 41356 of entire boost-root tree. [SVN r41370] --- bind.html | 2 +- bind_visitor.cpp | 38 ++-------------- test/Jamfile.v2 | 2 + test/bind_placeholder_test.cpp | 83 ++++++++++++++++++++++++++++++++++ test/bind_rvalue_test.cpp | 81 +++++++++++++++++++++++++++++++++ 5 files changed, 171 insertions(+), 35 deletions(-) create mode 100644 test/bind_placeholder_test.cpp create mode 100644 test/bind_rvalue_test.cpp 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 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); } diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index f8b7813..b88d49e 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -25,6 +25,8 @@ test-suite "bind" [ 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 ] diff --git a/test/bind_placeholder_test.cpp b/test/bind_placeholder_test.cpp new file mode 100644 index 0000000..174dd82 --- /dev/null +++ b/test/bind_placeholder_test.cpp @@ -0,0 +1,83 @@ +#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 +{ +}; + +namespace boost +{ + +template< int I > struct is_placeholder< custom_placeholder< I > > +{ + enum { value = I }; +}; + +} // namespace boost + +int main() +{ + int const x1 = 1; + int const x2 = 2; + int const x3 = 3; + int const x4 = 4; + int const x5 = 5; + int const x6 = 6; + int const x7 = 7; + int const x8 = 8; + int const x9 = 9; + + custom_placeholder<1> p1; + custom_placeholder<2> p2; + custom_placeholder<3> p3; + custom_placeholder<4> p4; + custom_placeholder<5> p5; + custom_placeholder<6> p6; + custom_placeholder<7> p7; + custom_placeholder<8> p8; + custom_placeholder<9> p9; + + BOOST_TEST( + boost::bind( f, p1, p2, p3, p4, p5, p6, p7, p8, p9 ) + ( x1, x2, x3, x4, x5, x6, x7, x8, x9 ) == 987654321L ); + + return boost::report_errors(); +} 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 e22e641bbf93f048b0eb207e6993e30103bdf0e8 Mon Sep 17 00:00:00 2001 From: Anthony Williams Date: Wed, 18 Jun 2008 13:01:08 +0000 Subject: [PATCH 12/34] Merge of new boost.thread code along with required changes from boost.bind [SVN r46474] --- bind.html | 99 ++++++++++--- include/boost/bind.hpp | 30 ++++ include/boost/bind/bind_mf2_cc.hpp | 228 +++++++++++++++++++++++++++++ test/Jamfile.v2 | 5 + test/bind_and_or_test.cpp | 84 +++++++++++ test/bind_fn2_test.cpp | 171 ++++++++++++++++++++++ test/bind_fnobj2_test.cpp | 76 ++++++++++ test/bind_lookup_problem_test.cpp | 2 +- test/bind_mf2_test.cpp | 162 ++++++++++++++++++++ test/ref_fn_test.cpp | 81 ++++++++++ 10 files changed, 916 insertions(+), 22 deletions(-) create mode 100644 include/boost/bind/bind_mf2_cc.hpp create mode 100644 test/bind_and_or_test.cpp create mode 100644 test/bind_fn2_test.cpp create mode 100644 test/bind_fnobj2_test.cpp create mode 100644 test/bind_mf2_test.cpp create mode 100644 test/ref_fn_test.cpp diff --git a/bind.html b/bind.html index 36ea678..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;

@@ -188,6 +189,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 @@ -285,21 +307,23 @@ 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, - 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" );

+

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:

@@ -362,10 +386,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);
@@ -373,17 +399,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?

@@ -528,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: @@ -859,7 +916,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 +947,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.

    diff --git a/include/boost/bind.hpp b/include/boost/bind.hpp index e1076e0..07b84d3 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) @@ -1542,6 +1568,7 @@ template +#include #undef BOOST_BIND_MF_NAME #undef BOOST_BIND_MF_CC @@ -1552,6 +1579,7 @@ template +#include #undef BOOST_BIND_MF_NAME #undef BOOST_BIND_MF_CC @@ -1564,6 +1592,7 @@ template +#include #undef BOOST_BIND_MF_NAME #undef BOOST_BIND_MF_CC @@ -1576,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 b88d49e..38fb264 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -27,10 +27,15 @@ test-suite "bind" [ run bind_visit_test.cpp ] [ run bind_placeholder_test.cpp ] [ run bind_rvalue_test.cpp ] + [ run bind_and_or_test.cpp ] [ run mem_fn_test.cpp ] [ run mem_fn_void_test.cpp ] [ run mem_fn_derived_test.cpp ] [ run mem_fn_eq_test.cpp ] [ run mem_fn_dm_test.cpp ] [ run mem_fn_rv_test.cpp ] + [ run ref_fn_test.cpp ] + [ run bind_fnobj2_test.cpp ] + [ run bind_fn2_test.cpp ] + [ run bind_mf2_test.cpp ] ; 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(); +} 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_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 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(); +} 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 45720b6f2df094dfbb9c74a381436d16f1aa8f22 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 28 Sep 2008 15:05:17 +0000 Subject: [PATCH 13/34] Merge 48832-48840 from trunk. [SVN r48989] --- 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 85d146117ea6c54303d54e8db40d16dc20a8ae6d Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Sat, 24 Jan 2009 18:57:20 +0000 Subject: [PATCH 14/34] merge of cmake build files from trunk per beman [SVN r50756] --- CMakeLists.txt | 22 ++++++++++++++++++++++ module.cmake | 1 + test/CMakeLists.txt | 30 ++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 module.cmake 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/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 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..7dd5a71 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,30 @@ +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 387e536a0a9b94cb3316fa44943849352cf53f34 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Mon, 23 Feb 2009 18:39:32 +0000 Subject: [PATCH 15/34] Merge PDF build changes from Trunk. [SVN r51417] --- doc/Jamfile.v2 | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 doc/Jamfile.v2 diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 new file mode 100644 index 0000000..f59b823 --- /dev/null +++ b/doc/Jamfile.v2 @@ -0,0 +1,13 @@ +# 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 + : + pdf:boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html + ; + From 8f507b9aeca643ca78e6a712b6d300720627c0ed Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 2 Mar 2009 16:15:40 +0000 Subject: [PATCH 16/34] Merge [51487] [51488] [51489] to release. Closes #2238. [SVN r51530] --- include/boost/bind.hpp | 1705 +------------------------------- include/boost/bind/bind.hpp | 1719 +++++++++++++++++++++++++++++++++ include/boost/bind/mem_fn.hpp | 389 ++++++++ include/boost/mem_fn.hpp | 375 +------ 4 files changed, 2118 insertions(+), 2070 deletions(-) create mode 100644 include/boost/bind/bind.hpp create mode 100644 include/boost/bind/mem_fn.hpp 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 new file mode 100644 index 0000000..7eb1dd2 --- /dev/null +++ b/include/boost/bind/bind.hpp @@ -0,0 +1,1719 @@ +#ifndef BOOST_BIND_BIND_HPP_INCLUDED +#define BOOST_BIND_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_BIND_HPP_INCLUDED diff --git a/include/boost/bind/mem_fn.hpp b/include/boost/bind/mem_fn.hpp new file mode 100644 index 0000000..956e7d8 --- /dev/null +++ b/include/boost/bind/mem_fn.hpp @@ -0,0 +1,389 @@ +#ifndef BOOST_BIND_MEM_FN_HPP_INCLUDED +#define BOOST_BIND_MEM_FN_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// mem_fn.hpp - a generalization of std::mem_fun[_ref] +// +// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. +// Copyright (c) 2001 David Abrahams +// Copyright (c) 2003-2005 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/bind/mem_fn.html for documentation. +// + +#include +#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_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 465899b2acc7597c5acfaab8abe0972e06f4d18f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 2 Mar 2009 16:26:24 +0000 Subject: [PATCH 17/34] Merge [51510] to release. [SVN r51532] --- 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 18b0dd3e175fbb6c21b277da3aa80d790981f1b9 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 2 Mar 2009 16:29:22 +0000 Subject: [PATCH 18/34] Merge [51511] to release. Closes #2127. [SVN r51533] --- 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 6431906dcc0f1fbafe0c667f9f624631de21078b Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 2 Mar 2009 16:32:03 +0000 Subject: [PATCH 19/34] Merge [51512] to release. Closes #2128. [SVN r51534] --- 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 a5f729bbeb674ae331a75c4110e6da992606209d Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 28 Mar 2009 20:56:16 +0000 Subject: [PATCH 20/34] Merge [51979] to release. Closes #2849. [SVN r52041] --- 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 7e1ad242f94f84d3830a51ddadf8f54bb20fa364 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Wed, 15 Apr 2009 13:01:15 +0000 Subject: [PATCH 21/34] Merged [52384] from trunk. [SVN r52405] --- 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 a060765e8b262a7d444d16dfe9aa2927fd694d4c Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Thu, 14 May 2009 20:20:34 +0000 Subject: [PATCH 22/34] shared_ptr and bind cmake tweaks [SVN r53001] --- test/CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7dd5a71..d39044b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -15,12 +15,23 @@ SET(tests bind_rv_sp_test bind_dm3_test bind_visit_test + bind_placeholder_test + bind_rvalue_test + bind_and_or_test mem_fn_test mem_fn_void_test mem_fn_derived_test mem_fn_eq_test mem_fn_dm_test mem_fn_rv_test + ref_fn_test + bind_fnobj2_test + bind_fn2_test + bind_mf2_test + bind_eq2_test + mem_fn_ref_test + bind_ref_test + bind_eq3_test ) FOREACH(test ${tests}) boost_test_run(${test}) From 52d9c13d6e22abd445d04103489beb2883d66fe2 Mon Sep 17 00:00:00 2001 From: Ronald Garcia Date: Wed, 3 Jun 2009 14:36:08 +0000 Subject: [PATCH 23/34] Merged change over from trunk. Added documentation for unwrap_ref. [SVN r53601] --- 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 c0d14f5e7c808c594fb1fbe4f3fac58d41c4595e Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Wed, 22 Jul 2009 21:51:01 +0000 Subject: [PATCH 24/34] Add basic copyright/license to keep cmake out of the inspection report [SVN r55095] --- 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 d39044b..9512e2e 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 961c3c5fa99103d80252c0235fe3ff8a262af3fb Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 8 Aug 2009 22:59:06 +0000 Subject: [PATCH 25/34] Merge [54385] to release. [SVN r55478] --- 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 8b58b0d2071d700e3b8c5d7541e6081cb2fd1615 Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Sat, 17 Oct 2009 01:10:45 +0000 Subject: [PATCH 26/34] rm cmake from the release branch before it goes out broken. Policy dictates that you never commit to release, you commit to trunk and merge to release. [SVN r56941] --- CMakeLists.txt | 28 --------------------------- module.cmake | 1 - test/CMakeLists.txt | 47 --------------------------------------------- 3 files changed, 76 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 9512e2e..0000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,47 +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 - bind_placeholder_test - bind_rvalue_test - bind_and_or_test - mem_fn_test - mem_fn_void_test - mem_fn_derived_test - mem_fn_eq_test - mem_fn_dm_test - mem_fn_rv_test - ref_fn_test - bind_fnobj2_test - bind_fn2_test - bind_mf2_test - bind_eq2_test - mem_fn_ref_test - bind_ref_test - bind_eq3_test - ) -FOREACH(test ${tests}) - boost_test_run(${test}) -ENDFOREACH(test ${tests}) - -boost_test_compile(bind_unary_addr) - From 00b3c895fddc638cebf837139776c6b58c2844d7 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 26 Nov 2009 22:16:17 +0000 Subject: [PATCH 27/34] Merge [57542] to release. Fixes #3601. [SVN r57961] --- 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 70f0c8efbb3ddd20578fe751f78d3d1473b03746 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 30 Nov 2009 20:30:22 +0000 Subject: [PATCH 28/34] Merge [57954], [57955] to release. [SVN r58066] --- 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 6e208277e3839b650f979efc4ee3d5b50432163f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 3 Dec 2009 17:44:37 +0000 Subject: [PATCH 29/34] Merge [58073], [58093] to release. Fixes #3003. [SVN r58119] --- include/boost/bind/mem_fn_template.hpp | 81 ++++++++----- test/Jamfile.v2 | 1 + test/mem_fn_unary_addr_test.cpp | 151 +++++++++++++++++++++++++ 3 files changed, 206 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..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, &u); + 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, &u); + 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, &u); + 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, &u, 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, &u, 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, &u, 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, &u, 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, &u, 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, &u, a1, a2); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2); } R operator()(T const & t, A1 a1, A2 a2) const @@ -386,14 +395,16 @@ public: template R operator()(U & u, A1 a1, A2 a2, A3 a3) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template R operator()(U const & u, A1 a1, A2 a2, A3 a3) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3); } #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, &u, a1, a2, a3); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3); } R operator()(T const & t, A1 a1, A2 a2, A3 a3) const @@ -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, &u, a1, a2, a3, a4); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4); } #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, &u, a1, a2, a3, a4); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4); } R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4) const @@ -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, &u, a1, a2, a3, a4, a5); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5); } #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, &u, a1, a2, a3, a4, a5); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5); } R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const @@ -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, &u, a1, a2, a3, a4, a5, a6); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6); } #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, &u, a1, a2, a3, a4, a5, a6); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6); } R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const @@ -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, &u, a1, a2, a3, a4, a5, a6, a7); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7); } #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, &u, a1, a2, a3, a4, a5, a6, a7); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7); } R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const @@ -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, &u, a1, a2, a3, a4, a5, a6, a7, a8); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7, a8); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7, a8); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7, a8); } #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, &u, a1, a2, a3, a4, a5, a6, a7, a8); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7, a8); } R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const 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..61e9160 --- /dev/null +++ b/test/mem_fn_unary_addr_test.cpp @@ -0,0 +1,151 @@ +#include +#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_; + } +}; + +#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 ) + { + 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 787d3cb7b422c6abf3cebd59ad42461370bcbaf4 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 26 Jun 2010 12:30:09 +0000 Subject: [PATCH 30/34] Merge documentation fixes. * Use `doc/src/*.css` instead of `doc/html/*.css`. * Remove wiki and people directories. * Some documentation fixes. * Left out `minimal.css` changes and boostbook changes because of clashes. [SVN r63347] --- 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 7b89dd7fd99ff040fc6a51f78aed050c9dbd0979 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 10 Jul 2010 21:26:25 +0000 Subject: [PATCH 31/34] Merge [62251] to release. Fixes #4172. [SVN r63828] --- 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 c53ba15ce5b6c80a2d98c3fcd0aca958d783c01a Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Sun, 5 Dec 2010 22:18:05 +0000 Subject: [PATCH 32/34] Merge doc fix to release; fixes #4532 [SVN r67047] --- 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 fa8debfc809b5e786662a65254ca6365499f05fb Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 30 Nov 2011 17:53:38 +0000 Subject: [PATCH 33/34] Merge [75391] to release. Fixes #5792. [SVN r75755] --- 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 6315df35d69b3ad911358bdf2178192a1613207c Mon Sep 17 00:00:00 2001 From: Michel Morin Date: Wed, 13 Nov 2013 03:22:55 +0000 Subject: [PATCH 34/34] Merge r86524 (Correct broken links to C++ standard papers); fixes #9212 [SVN r86673] --- 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