Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2000-11-22 15:05:18


From: "Douglas Gregor" <gregod_at_[hidden]>

> > Is it? I've never used the AdaptableBinaryFunction concept. Neither
function
> > pointers nor lambda/expression.hpp generated function objects are
> > AdaptableBinaryFunctions.
>
> Function pointers (and their arguments) can be picked out in function
calls,
> however.

Sorry, I don't quite understand what you mean...

template<class R, class A> void f(R (*g) (A)); // perhaps this?

template<class R, class A> void f(callback<R, A> g); // isn't this
equivalent?

> > The concept was useful back at the time when the STL was designed (no
> > partial specialization) but we have traits and other techniques
available
> > now.
>
> Traits don't help function pointers either.

They don't in the sense that you can't combine a function pointer with the
other STL-supplied functors (the <functional> way.) (Unless you use
boost/functional.hpp, of course.) However, if you have a lambda library at
your disposal, <functional> becomes obsolete pretty quickly. :-)

> Perhaps AdaptableBinaryFunction is a dead concept, but I'd like to see a
dominant
> functor_traits which accomodates all functors before I throw away
> AdaptableBinaryFunction completely.

You can't fit 'modern-day' functors into the AdaptableBinaryFunction model.
arg1+arg2 generates something along the lines of

struct plus
{
    template<class A1, class A2> typeof(a1+a2) operator()(A1 a1, A2 a2)
    {
        return a1+a2;
    }
};

--
Peter Dimov
Multi Media Ltd.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk