0

A collegue said to me that he doesn't see the benefits of using auto in C++11, because it can create troubles with the types of the variables.

What do you guys think?

Which are for you the benefits and disadvantage of using auto in your code?

Piotr Skotnicki
  • 46,953
  • 7
  • 118
  • 160
Astinog
  • 1,151
  • 3
  • 12
  • 35
  • See this post: http://stackoverflow.com/questions/32052786/reasons-to-use-the-auto-keyword-in-c11/32052997 – vincentp Aug 20 '15 at 11:55
  • Opinion: You should know what type your variables are - do it the old, clear and explicit way – FreelanceConsultant Aug 20 '15 at 12:05
  • That is discussed so often that there is no need to do it here again. There are also in SO some discussions but more are in the web. I will not reference on them, because they are already referenced in the SO questions which you wrote your duplicate on. – Klaus Aug 20 '15 at 12:11
  • You may want to read http://herbsutter.com/2013/06/13/gotw-93-solution-auto-variables-part-2/ and http://herbsutter.com/2013/08/12/gotw-94-solution-aaa-style-almost-always-auto/ – Michael Aug 20 '15 at 12:12
  • I personally prefer typing `auto` instead of something ludicrously long like `std::chrono::high_resolution_clock::time_point` :) If I would have to bring up actual technical reasons, I would say go watch [this presentation](https://www.youtube.com/watch?v=xnqTKD8uD64&feature=youtu.be&t=1705) – notadam Aug 20 '15 at 12:14
  • Don't listen to Herb. Your colleague is right. – Lightness Races in Orbit Aug 20 '15 at 12:19

0 Answers0