|
Boost Users : |
Subject: Re: [Boost-users] Help with bind usage
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2011-08-01 21:54:53
> Suppose I have something that expects a general function object that takes three parameters.
> I have a function that takes one parameter, and I don't care about the other two.
> How do I get an instance func that when called as func(a,b,c) will end up calling my
> function foo as foo(a) and throw away the other two?
>
> If I use bind, I wind up with a functor that takes fewer arguments than the original. But
> here I have more.
You don't need to do anything special; function objects produced by bind can already
be called with extra arguments and they ignore the extra ones.
i.e. just do "func = bind(foo, _1)", and "func(a, b, c)" will be valid and equivalent
to "foo(a)"
Regards,
Nate
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net