Usage of "auto". What for?

?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

The "auto" keyword is not yet part of the C++ language. The document
Sylvester referred to is related to a proposal for the next revision
of the C++ standard. So, currently, it should strictly be treated as
a compiler-specific language extension. Therefore, to understand what
"auto" does in your case, you need to refer to your compiler's
documentation.

Please quote the relevant sections you are replying to, since it will
make your post a lot easier to understand.

The keyword "auto" has been part of the C++ language for some time
(probably since the beginning) and it specifies that a variable shall
have automatic storage duration. However it is hardly ever used since
automatic storage duration is the default so the absence of presence of
it does not affect the semantics of the code.

The document Sylvester referred to describes a new usage of the auto
keyword, and as you pointed out it is not yet a part of the C++ language.

To understand what the code someone (I don't know who) posted does one
would need to know if he was talking about the current version of C++ or
the next, however considering that the current usage of auto is quite
trivial to understand one can assume that it was the semantics in the
next language he was talking about, in which case the working draft of
the new standard (currently document n2284) would probably be the best
source for information.
 
J

James Kanze

I have not read the proposal fully - while browsing through the proposed
wording, I saw that they removed 'auto' from the storage class specifiers in
7.1.1, which made me believe the old behaviour of auto would disappear. My
bad.

That was my first reaction, too, and that it would mean
rejection of the proposal by some of the national bodies. But
I've been through this before---I know that backwards
compatibility and not breaking existing code are important
considerations. The committee tries to not act irresponsibly.
So I read further, and found that, while no longer one of the
storage class specifiers, it acts exactly like one any time a
type specifier is present.
 
J

James Kanze

The "auto" keyword is not yet part of the C++ language. The
document Sylvester referred to is related to a proposal for
the next revision of the C++ standard. So, currently, it
should strictly be treated as a compiler-specific language
extension. Therefore, to understand what "auto" does in your
case, you need to refer to your compiler's documentation.


The auto keyword has been part of C++ (and C) since the very
beginning. It's described in the first edition of K&R, and has
remained in all successor versions of C and C++, with the same
meaning. The proposal cited by Sylvester is to extend its
meaning to new cases, which are currently illegal.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,294
Messages
2,571,511
Members
48,216
Latest member
DarrelLho

Latest Threads

Top