Boost logo

Boost-Commit :

From: pdimov_at_[hidden]
Date: 2008-02-19 09:51:10


Author: pdimov
Date: 2008-02-19 09:51:10 EST (Tue, 19 Feb 2008)
New Revision: 43319
URL: http://svn.boost.org/trac/boost/changeset/43319

Log:
Fix #1641.
Text files modified:
   trunk/libs/bind/bind.html | 25 +++++++++++++++++++++++--
   1 files changed, 23 insertions(+), 2 deletions(-)

Modified: trunk/libs/bind/bind.html
==============================================================================
--- trunk/libs/bind/bind.html (original)
+++ trunk/libs/bind/bind.html 2008-02-19 09:51:10 EST (Tue, 19 Feb 2008)
@@ -188,6 +188,27 @@
 </pre>
                 <p>[Note: the ability to omit the return type is not available on all compilers.]
                 </p>
+ <P>By default, <STRONG>bind</STRONG> makes a copy of the provided function object. <code>
+ boost::ref</code> and <code>boost::cref</code> 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.</P>
+ <pre>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 );
+</pre>
                 <h3><a name="with_member_pointers">Using bind with pointers to members</a></h3>
                 <p>Pointers to member functions and pointers to data members are not function
                         objects, because they do not support <tt>operator()</tt>. For convenience, <b>bind</b>
@@ -859,7 +880,7 @@
                         by Jaakko Järvi;
                         <li>
                                 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);
                         <li>
                                 <a href="http://more.sourceforge.net/">Extensions to the STL</a> by Petter
@@ -890,7 +911,7 @@
                         <br>
                         <br>
                         <small>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.</small></p>
         </body>


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