Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-02-21 10:28:32


From: "Peter Dimov" <pdimov_at_[hidden]>
> int & expr();
>
> auto x = expr();
>
> We want
>
> int x = expr();
>
> and not
>
> int & x = expr();
>
> that will leave us with a dangling reference.

Hmm, scratch that. :-) It will not leave us with a dangling reference, only
with a 'x' that may not match our expectations.

The exact semantics of the auto declaration depend on its intended use. In
the common case where auto declarations are used to introduce named
temporaries, as in

auto tmp(*first);
while(++first != last) tmp += *first;

we don't need the temporary to be a reference, or be const. This is why
existing typeof()s strip references and const; they are mostly used for auto
declarations.


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