
C++ “auto” considered (mostly) harmful - ingve
http://denisbider.blogspot.com/2015/11/auto-considered-mostly-harmful.html
======
makecheck
Well, the examples could probably be better here.

The first example comparing references to copies ignores the fact that you can
certainly say "const auto &x = Function();". And really, there's no harm in
doing that all the time; if the result is actually returned by value, you'll
end up with a stable reference to a temporary object that is only destroyed at
scope exit time.

Similarly, I see nothing wrong with consistently saying things like "for
(const auto &someObject : someContainer) ..." because it really doesn't help
the user to keep typing out all that template garbage each time, and actually
introduces unnecessary dependencies on those specifics when the class changes.
In fact, ever since lambdas and std::function<> came along, I don't even
_want_ APIs that expose things like map types and iterators directly; I much
prefer having simple forEach() methods that call whatever function I want,
hiding the specifics of the container(s) inside the object.

A case where I really like "auto" is for stuff like "auto x = new
ObnoxiouslyLongClassName::ObnoxiouslyLongSubclass();" because it's completely
clear and doesn't require repetition of unfortunately-named objects.

