Search code examples
c++c++11historyautoc++03

What was `auto` used for before?


I know that before C++11 the auto keyword had a completely different meaning; it was a storage type specifier indicating an object that has automatic storage type (ie, placed on the stack).

That's how the theory goes... How would you actually use this keyword (syntax), and why? Also, I haven't seen this keyword in actual code pre-C++11; when was it useful (what time period)?


Solution

  • It was used to declare a local variable with automatic storage duration (i.e., "on the stack").

    At least since C90 it has been a useless keyword, since automatic storage duration is the default storage duration for a local variable.