Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2000-11-23 10:54:55


On Wed, 22 Nov 2000 22:05:18 +0200
"Peter Dimov" <pdimov_at_[hidden]> wrote:

> 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?

Yes, but I was referring to:
template<class Functor> void f(Functor g);

where we cannot be the functor parameter types without an external traits class or the knowledge that it models an adaptable function concept.

> > > 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. :-)

I don't think we have the lambda library at our disposal in the common compiler case :(.

> > 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;
> }
> };
>

Please excuse my ignorance. Is typeof() en route to standardization?

        Doug Gregor


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