Home | Libraries | People | FAQ | More |
The header
As well as the corresponding helper functions
The key benefit of these adapters over those in the Standard Library is they avoid the problem of references to references.
Usage is identical to the standard binders. For example,
class Foo { public: void bar(std::ostream &); // ... }; // ... std::vector<Foo> c; // ... std::for_each(c.begin(), c.end(), boost::bind2nd(boost::mem_fun_ref(&Foo::bar), std::cout));
Consider the usage example above
class Foo { public: void bar(std::ostream &); // ... }; // ... std::for_each(c.begin(), c.end(), boost::bind2nd(boost::mem_fun_ref(&Foo::bar), std::cout));
If this had been written using
The problem arises because
The call to
template <class Operation> class binder2nd : public unary_function<typename Operation::first_argument_type, typename Operation::result_type> { ... public: binder2nd(const Operation& x, const typename Operation::second_argument_type& y); ...
Since our operation's
The binders in this library avoid this problem by using the Boost
Our constructor is declared
binder2nd(const Operation& x, typename call_traits< typename binary_traits<Operation>::second_argument_type >::param_type y)
As a result, y has a type of
Copyright © 2000 Cadenza New Zealand Ltd. 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.
Revised 28 June 2000