Boost logo

Boost Users :

From: Jaakko Järvi (jarvi_at_[hidden])
Date: 2006-11-28 21:00:31


On Nov 28, 2006, at 5:49 PM, Peter Dimov wrote:

> Rodolfo Lima wrote:
>
>>> function<int(const aux &)> f = (&_1->*&aux::a)();
>>
>> This doesn't work because you are evaluating the functor without
>> arguments, whereas it requires one.
>
> You are right, it doesn't work; lambda's operator->* seems a pretty
> odd
> beast. Interesting that nobody has discovered its quirks so far.
> FWIW, the
> syntax above is how it should work in order to be usable. Lambda
> currently
> implements
>
> aux x;
>
> (&_1->*&aux::a)( x )();
>
> instead of
>
> (&_1->*&aux::a)()( x );
>
> The current functionality doesn't make much sense to me; if you had
> x at the
> time the lambda expression is constructed, you could have used it
> directly
> and skip the _1 business.

The reasoning is (or was :) that using a placeholder in an expression
does nothing more than
delays the evaluation of that expression.

So

(&_1->*&aux::a)( x )

should have the same semantics as

&x->*&aux::a

This is how all other operators (+, -, ...) work in Lambda.

In the case of ->* this seems in deed confusing, and potentially a
less strict interpretation
of this principle might be more useful.

Cheers, Jaakko


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