Index: libs/bind/bind.html =================================================================== --- libs/bind/bind.html (revision 66798) +++ libs/bind/bind.html (working copy) @@ -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 @@ 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: