After having it available for over 10 years now, and seeing lots of use of it, the use of auto is generally not a good idea in Gnucap.

Working with some item, looking at its declaration, the type is most relevant. “auto” requires looking elsewhere, which normally makes the code harder to read and understand.

If there is real benefit in its use, the use of auto is allowed. Overuse without benefit is not, especially when the type becomes implicit or obscure. The examples below are all of the type with little benefit of auto. But since the type is explicit on the same line, it isn't terrible.

auto ptr = new TYPE(args);
auto ptr = some_case<NEW_TYPE*>(thing);

if(auto ptr = dynamic_cast<NEW_TYPE*>(thing)){
  [..]
}
gnucap/manual/tech/auto.txt · Last modified: 2022/11/25 01:33 by felixs
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Run by Debian Driven by DokuWiki