Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-03-08 13:40:23


Gabriel Dos Reis wrote:
> Jaakko Jarvi <jajarvi_at_[hidden]> writes:
>
>> My example was a bit contrived too.
>> Here's another example (with imaginary syntax):
>>
>> auto foo() {
>> int i;
>> return auto(int x) { return i + x; }
>> }
>
> Is it different from
>
> int& f() { int i; return i; }
>
> ?

Yes, it's a bit different, since the reference return is explicit. I can
choose between "int & f()" and "int f()" and the semantics are fairly
straightforward.

In a lambda, bind by value and bind by reference are equally useful, and we
should have a (straightforward) way to choose between them. And it seems to
be that the default should be by value since it's safe, and by-ref should
probably be designated by the usual ref(i) construct (*&i is also an option,
but it's somewhat of a wart).


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