https://gist.github.com/Eisenwave/5cca27867828743bf50ad95d526f5a6e
I've written an article about auto. You might be interested.
21 messages · Page 1 of 1 (latest)
https://gist.github.com/Eisenwave/5cca27867828743bf50ad95d526f5a6e
I've written an article about auto. You might be interested.
void Container::do_things() {
auto chunk = search_for_chunk();
add_extra_stuff_to_chunk(chunks);
use_somehow(std::move(chunk));
}
was the 3rd line supposed to be chunkS?
yeah, oops
the but feels weird inside a list
oh and
IDEs aren't alwasy available
misspell
nice text overall, especially the part about IDE
thanks, I've worked in your corrections
in the example about vector it is stated that instead of auto, vec3d should be used
but later that it is fine to use auto s = sqrt(x) because We also understand that a sqrt function should return the same type as the input., doesnt it apply to the end - start too?
the implication is that sqrt is scalar and not component-wise, so the dimensions can be inferred
in the p - q example, you cannot infer the amount of dimensions that the result has
okay and because it is scalar its small, cheap, numeric type so its fine to eg copy it instead of using ptrs/references
yeah
I mean, if you use sqrt then you basically know you're getting a trivially copable numeric scalar result
anything else would be extremely confusing
I'm really happy you've written it down. Most of these are conclusions I've had on my own, but couldn't precisely formulate that. This article addresses all the issues that I have either encountered or have seen people complain about before
One negative consequence of auto is that it hides whether have ownership over the objects involved.
is this a typo? or cannot i the english?
typo, fixed
Update: I've greatly expanded the article; it addresses many points made by Herb in https://herbsutter.com/2013/08/12/gotw-94-solution-aaa-style-almost-always-auto/