Boost logo

Boost :

From: Geurt Vos (G.Vos_at_[hidden])
Date: 2001-05-03 09:56:45


> > Idea 2:
> > function is there to take either a function or a
> > functor, while bind can be used to turn a member
> > function into a functor. I was just wondering,
> > wouldn't it be easier (and maybe even more
> > consistent) if 'bind' could take either a function
> > or a member function, and 'function' only functors?
>
> "bind" will take free functions (sometime in the future,) but "function"
> contains some specific optimizations for function pointers (it avoids
> dynamic allocations, AFAICT).
>

Fair enough.

BTW, about bind, I haven't really looked into it all,
but how 'complex' is it going to be? Consider the
following example:

class C {
public:
    void Func(int,int,int);
};

int main()
{
    C c;
    boost::function<void,int,int> f;
    f = boost::bind<1>(&C::Func,c,100);
    f(1,2); // will call C::Func(1,100,2)
}

Can bind do this or similar or is it too much?

Geurt


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