|
Boost : |
From: ali f (k9eks_at_[hidden])
Date: 2006-12-08 05:37:03
Boost.Bind can indeed be used to decrease the number of args a function can
take, but it can't be used to increase the number of args a function can
take. In the example I gave in my original post, the callback:
bool callback(int,int,bool,int);
and you have a functon
bool draw(int,int)
You can't use bind to assign "draw" to "callback". args_cast can be used
though.
- ali
----- Original Message -----
From: "me22" <me22.ca_at_[hidden]>
Newsgroups: gmane.comp.lib.boost.devel
Sent: Friday, December 08, 2006 6:30 PM
Subject: Re: new utility: function parameter caster
> On 12/7/06, ali f <k9eks_at_[hidden]> wrote:
>> a) wrap the function in a struct and overload operator ()
>> b) change the signature (but then change all places where you've invoked
>> the
>> function already)
>>
> c) Use Boost.Bind.
>
>>From http://boost.org/libs/bind/bind.html#with_functions :
> bind(f, _2, _1)(x, y); // f(y, x)
> bind(g, _1, 9, _1)(x); // g(x, 9, x)
> bind(g, _3, _3, _3)(x, y, z); // g(z, z, z)
> bind(g, _1, _1, _1)(x, y, z); // g(x, x, x)
> Note that, in the last example, the function object produced by
> bind(g, _1, _1, _1) does not contain references to any arguments
> beyond the first, but it can still be used with more than one
> argument. Any extra arguments are silently ignored, just like the
> first and the second argument are ignored in the third example.
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk