Skip to content

That usage of auto is not... beautiful #47

@j-silver

Description

@j-silver

Beauty is in the eye of the beholder.

I almost always use auto (and I have a hard time with my line manager who opposes it with nonsensical reasons): we often don't need to spell out the type of local variables returned by functions, especially when they would be insanely verbose, plus, as you briefly explain at page 248, automatic type deduction avoids the implicit conversions we would have if we initialised with the wrong type.

However, the usage of auto at page 62 and later seem all but beautiful to me :-)

auto options = std::ifstream(filename);
...
auto key = std::string{};
auto value = std::string{};

Really? It's longer than

std::ifstream options{filename};
std::string key;

and we're not gaining anything, apart from a vague consistency in style, or are we trying to mimic Rust?

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