In a code review, I was told that a declaration and initialization of the form
auto someVar = false;
was bad because the auto
keyword in the declaration was out of place since the type is readily known. So the question posed to me was why force the compiler to perform an extra step in determining the type of someVar
. I was told the following form is more preferable
bool someVar = false;
I use auto
simply because I like to keep my code consistent and I've taken to using auto everywhere in my code except when auto
doesn't resolve to the type that I want. Is there a hard and fast rule when it comes to auto
when declaring simple types such as above or is it purely a matter of developer preference?
Aucun commentaire:
Enregistrer un commentaire