Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
j-silver opened this issue Oct 15, 2022 · 0 comments
Open

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

j-silver opened this issue Oct 15, 2022 · 0 comments

Comments

@j-silver
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant