|
Boost : |
From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-04-17 18:20:21
On Wednesday 17 April 2002 05:48 pm, you wrote:
> And if you take me example, you see that bind() is used to redistribute the
> arguments. chain() just makes sure that all the arguments are correctly
> exposed. A bind-only solution would be something weird like:
>
> bind2(foo, _1, _2)(bar, _3, _4);
> bind2(foo, _1, _2)(bar, _1, _2); // call both with the same parameters.
>
> Of course, the function objects returned by bind2() can't be called in any
> way, while bind2()() is "complete".
I see. I'm still not sure that the name 'chain' is best for this task. Maybe
something like 'join' or 'combine'?
> > There is one technical issue with implementing your suggestion: we don't
>
> know
>
> > the relative arities of 'foo' and 'bar'. For instance:
> >
> > do_something(bind(chain(foo, bar), _1, _2, _1, _3, _2));
> >
> > How many arguments does 'foo' get?
[snip code]
> Or did I misunderstand the problem?
>
> Giovanni Bajo
No, you understood the problem correctly. And while arity traits are fine,
they aren't there for already-existing function objects (and there are a LOT
of function objects out there). Note that a Lambda-only or Bind-only solution
(the Lambda solution is much cleaner) doesn't require these types of traits.
Doug
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk