4 ms·
He's not advocating "auto everywhere", he just said it will make the STL algorithms easier to use (which it will). The other benefit of auto is for generic cod
by phaedrus 15y ago
He's not advocating "auto everywhere", he just said it will make the STL algorithms easier to use (which it will). The other benefit of auto is for generic code (code in templates) where you might not necessarily know what the return type is, or at least where the return type is going to be very complicated to specify. (This last is the same reason C# added var at the same time as they added LINQ - the return types of LINQ expressions would be difficult to specify manually.)
- pandaman 15y agoHe says "Use C++11 auto wherever possible." Nobody argues auto and decltype is necessary for generic code but this not what Sutter's writing about. In fact he does not have a single word like "generic" or "template" in his entire article. Which alone should be a good indication this has nothing to do with the modern C++ style unlike Alexandrescu's book with the similar name.