Data types can hide behind auto making our code less readable at times. This is a good discussion on the same:
https://www.reddit.com/r/cpp_questions/comments/1doyqd8/should_we_still_almost_always_use_auto/
Personally, I would prefer we only use auto when we are saving quite a few characters, like the example in a comment in the aforementioned discussion:
class MyStruct;
std::map<std::pair<std::string, int>,
std::vector<std::unique_ptr<MyStruct>>> vec;
for (auto i = vec.begin(), e = vec.end(); i != e; ++i) {
// ...
}
This makes sense, because it is very obvious what auto converts too. But in cases where it is not obvious, and we are using auto because we are unsure what type we should be setting, I believe we should rethink our use of auto.
Data types can hide behind
automaking our code less readable at times. This is a good discussion on the same:https://www.reddit.com/r/cpp_questions/comments/1doyqd8/should_we_still_almost_always_use_auto/
Personally, I would prefer we only use
autowhen we are saving quite a few characters, like the example in a comment in the aforementioned discussion:This makes sense, because it is very obvious what
autoconverts too. But in cases where it is not obvious, and we are usingautobecause we are unsure what type we should be setting, I believe we should rethink our use ofauto.