![]() |
Home | Libraries | People | FAQ | More |
The header
as well as the corresponding overloaded helper functions
The following changes have been made to the adapters as specified in the Standard:
The standard specifies
template <class S, class T, class A> class const_mem_fun1_t : public binary_function<T*, A, S> { public: explicit const_mem_fun1_t(S (T::*p)(A) const); S operator()(const T* p, A x) const; };
Note that the first argument to
Does this matter? Well, consider what happens when we write
struct Foo { void bar(int) const; }; const Foo *cp = new Foo; std::bind1st(std::mem_fun(&Foo::bar), cp);
We have created a
typedef Foo* first_argument_type;
The
This hack will not suffice with the improved binders in this library, so we have had to provide corrected versions of the member function adapters as well.
The standard defines
template <class S, class T, class A> class mem_fun1_t : public binary_function<T*, A, S> { public: explicit mem_fun1_t(S (T::*p)(A)); S operator()(T* p, A x) const; };
Note that the second argument to
However, if we were to try and eliminate this inefficiency by
instead declaring the argument as
So the way in which we want to declare the second argument for
The Boost
S operator()(T* p, typename call_traits<A>::param_type x) const
we achieve the desired result - we improve efficiency without generating references to references.
The call traits template used to realise some improvements relies
on partial specialisation, so these improvements are only available on
compilers that support that feature. With other compilers, the
argument passed to the member function (in the
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