3 ms·
Quoting Herb Sutter, "AAA Style (Almost Always Auto)": "Guideline: Remember that preferring auto variables is motivated primarily by correctness, performance,
by ingve 11y ago
Quoting Herb Sutter, "AAA Style (Almost Always Auto)":
"Guideline: Remember that preferring auto variables is motivated primarily by correctness, performance, maintainability, and robustness—and only lastly about typing convenience." [1]
http://herbsutter.com/2013/08/12/gotw-94-solution-aaa-style-almost-always-auto/ http://herbsutter.com/2013/08/12/gotw-94-solution-aaa-style-...
- StephanTLavavej 11y agoauto variables are different from trailing return types introduced by auto (a particularly egregious appropriation of a keyword for a totally different use).
- pmelendez 11y ago> a particularly egregious appropriation of a keyword for a totally different use Which seems to be an often case in C++, class and class/typename comes to my mind. Also, old auto use was removed to the new set of meaning right?
- StephanTLavavej 11y agoOld auto was completely removed.
- nadams 11y ago> correctness, performance, maintainability, and robustness What? I want whatever he is smoking. > correctness C++ allows for casting to/from different types (the core behind polymorphism) - but if you cast to the wrong type then that's your own fault. If you want a warm fuzzy feeling of not worrying about bad casts - use Python/Go/FreeBASIC/some other language. > performance That is complete and utter delusion. Your program won't run any faster or optimize better because you used the auto keyword [1]. If anything - it will take even longer (ms longer) to compile. > maintainability I have an odd feeling about that. Yeah you can change the return type of a method or function and you don't have to worry about changing the code calling those methods/functions. But if you are changing to a vastly different type - you are going to have to change the calling code anyways. > robustness I don't want the compiler to fix my mistakes. I want the compiler to tell me how stupid I am and force me to fix them. [1] http://stackoverflow.com/questions/19618759/c-11-auto-compile-time-or-runtime http://stackoverflow.com/questions/19618759/c-11-auto-compil...