Skip to content

Reasses our uses of auto #241

Description

@adisidev

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions