Boost logo

Boost :

From: jaakko.jarvi_at_[hidden]
Date: 2001-11-15 17:20:07


I'm jumping into this discussion in the midde, so sorry if I got
something wrong. Just a few details:

> 3) Bind/Lambda can just wrap ref(x) in their own internal ref-like
classes to
> allow parameters to be ignored.
>
> I'm looking at "ref(x)" as essentially a directive that says "use a
reference
> to x instead of copying it". Bind and Lambda have a particular view
of how
> this should be done (by making it a function object that ignores its
> arguments),
ref(x) does not create a function object in lambda, it just wraps the
reference.

>
> struct negate {
> template<typename T> typeof(-T()) operator()(const T&) { return
-T; }
> };
>
> Now if I have an object "op" of type negate, and I have the Lambda
object
> -_1, it seems wrong that op(a, b) is ill-formed whereas (-_1)(a, b)
is -a. We
> shouldn't lose the arity constraint just because we're using Lambda.

(-_1)(a, b) fails at compile time in lambda, so the arity constraint
             is still there

As a side note:

(-_2)(a, b) works, argument a is discarded

So the highest placeholder index determines the arity of the lambda
functor.

Jaakko


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