$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r66973 - trunk/libs/bind
From: marshall_at_[hidden]
Date: 2010-12-02 08:17:14
Author: marshall
Date: 2010-12-02 08:17:09 EST (Thu, 02 Dec 2010)
New Revision: 66973
URL: http://svn.boost.org/trac/boost/changeset/66973
Log:
Doc patch; refs #4532
Text files modified: 
   trunk/libs/bind/bind.html |    43 ++++++++++++++++++++++++++++++++++++++++
   1 files changed, 43 insertions(+), 0 deletions(-)
Modified: trunk/libs/bind/bind.html
==============================================================================
--- trunk/libs/bind/bind.html	(original)
+++ trunk/libs/bind/bind.html	2010-12-02 08:17:09 EST (Thu, 02 Dec 2010)
@@ -61,6 +61,7 @@
                                 bind<R>(f, ...)</A></h4>
                 <h4 style="MARGIN-LEFT: 40pt">Binding a nonstandard function</h4>
                 <h4 style="MARGIN-LEFT: 40pt">Binding an overloaded function</h4>
+		<h4 style="MARGIN-LEFT: 40pt">Modeling STL function object concepts</h4>
                 <h4 style="MARGIN-LEFT: 40pt">const in signatures</h4>
                 <h4 style="MARGIN-LEFT: 40pt"><A href="#err_msvc_using">MSVC specific: using 
                                 boost::bind;</A></h4>
@@ -585,6 +586,48 @@
     boost::bind( get, _1 );
 }
 </pre>
+		<h3><a name="err_modeling_stl_function_object_concepts">Modeling STL function object concepts</a></h3>
+		<p>The function objects that are produced by <b>boost::bind</b> 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 <tt>result_type</tt> and <tt>argument_type</tt> or
+		<tt>first_argument_type</tt> and <tt>second_argument_type</tt>. In cases where these
+		typedefs are desirable, however, the utility function <tt>make_adaptable</tt>
+		can be used to adapt unary and binary function objects to these concepts. This allows
+		unary and binary function objects resulting from <b>boost::bind</b> to be combined with
+		STL templates such as std::unary_negate
+		and std::binary_negate.</p>
+		
+		<p>The <tt>make_adaptable</tt> function is defined in <boost/bind/make_adaptable.hpp>,
+		which must be included explicitly in addition to <boost/bind.hpp>:</p>
+		<pre>
+#include <boost/bind/make_adaptable.hpp>
+
+template <class R, class F> <i>unspecified-type</i> make_adaptable(F f);
+
+template<class R, class A1, class F> <i>unspecified-unary-functional-type</i> make_adaptable(F f);
+
+template<class R, class A1, class A2, class F> <i>unspecified-binary-functional-type</i> make_adaptable(F f);
+
+template<class R, class A1, class A2, class A3, class F> <i>unspecified-ternary-functional-type</i> make_adaptable(F f);
+
+template<class R, class A1, class A2, class A3, class A4, class F> <i>unspecified-4-ary-functional-type</i> make_adaptable(F f);
+		</pre>
+		
+		<p>This example shows how to use <tt>make_adaptable</tt> to make a predicate for "is not a space":</p>
+		<pre>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) ) );
+</pre>
+
+		<p>In this example, <b>boost::bind</b> creates the "is a space" (unary) predicate.
+		It is then passed to <tt>make_adaptable</tt> so that a function object modeling
+		the Unary Function concept can be created, serving as the argument to
+		std::not1.</p>
+		
                 <h3><a name="err_const_arg"><b>const</b> in signatures</a></h3>
                 <p>Some compilers, including MSVC 6.0 and Borland C++ 5.5.1, have problems with the 
                         top-level <b>const</b> in function signatures: