Boost logo

Boost :

From: Gabriel Dos Reis (gdr_at_[hidden])
Date: 2004-03-08 14:22:14


"Peter Dimov" <pdimov_at_[hidden]> writes:

| 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

I'm afraid, that changes nothing. From existing experiences.

| choose between "int & f()" and "int f()" and the semantics are fairly
| straightforward.

If you think it is just a matter of ref, then about the value-based
version

    int* f() { int i; return &i; }

There is no bit of difference, actually.
Unfortunately, it happens with people not noticing. [ That is how we
get books that teach people not doing it :-) ]

-- Gaby


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