2

I find the auto keyword to be very useful as I don't have to worry about the type outcome of evaluating a complex expression or having to worry about which type to use (in terms of the right size) when initializing a variable. Besides backwards compatibility, is there any reason why I shouldn't use auto or circumstances in which it's not wise to do so ?

Praetorian
  • 106,671
  • 19
  • 240
  • 328
Mutating Algorithm
  • 2,604
  • 2
  • 29
  • 66
  • I would never use `auto`. It doesn't do _anything_. What do you mean by "don't have to worry about the type outcome of evaluating a complex expression or having to worry about which type to use"? – Steve Summit Jul 03 '15 at 20:54
  • @SteveSummit auto variable = some_long_expression (type is unknown, could evaluate to double, int, etc.) – Mutating Algorithm Jul 03 '15 at 20:56
  • One argument against is that the actual type becomes hidden when reading the code. If you do multi-step transformations with auto, it can be quite hard to follow the type changes. – Alexander Torstling Jul 03 '15 at 20:59
  • 1
    Ah. It's an old, old keyword that's taken on a new life. I'm an old C programmer who hadn't heard of this new usage. – Steve Summit Jul 03 '15 at 20:59

0 Answers0