auto -> auto & var

Lionello Lunesu lio at remove.lunesu.com
Mon Mar 13 04:03:47 PST 2006


"Kramer" <Kramer_member at pathlink.com> wrote in message 
news:duspas$2dfo$1 at digitaldaemon.com...
>I keep tripping myself over the double meaning of auto.  I know it 
>shouldn't be
> that difficult to remember that auto means type inference and also stack
> allocation/RAII, but does it have to be that way?

Walter explained it: it does not have two meanings. The "auto" merely 
notifies the compiler (or lexer, I don't know) that it's a declaration and a 
variable name will follow.

When the compiler encounters "auto x" it knows "x" is a variable. Since 
"auto x" doesn't mention a type, it'll be derived.. Same thing for "static 
x", x must be a variable, but there's no type so it'll be derived.

L.





More information about the Digitalmars-d mailing list