6 ms·
A key difference is that we are being told to use auto (but not templates) gratuitously, even when there's only one possible type. I prefer to make functions o
by millstone 12y ago
A key difference is that we are being told to use auto (but not templates) gratuitously, even when there's only one possible type.
I prefer to make functions ordinary, and only templatize functions that need to operate on more than one type. There's good reasons for this: the compiler is less effective at type-checking templates, they require the function body to be visible, and they may fail to warn you when passed the wrong type.
"auto" suffers from all those problems, and yet we are being told to use it whenever possible. That's bad advice.