← Back to team overview

kicad-developers team mailing list archive

Re: "auto" policy

 

Le 05/04/2019 à 12:39, Jeff Young a écrit :
> Do we have a policy on when to use auto?
> 
> Personally, I like it when it removes repetition.  For instance:
> 
>     auto pin = new SCH_PIN();  
> 
> 
> And I like it when it removes stupid template things like std::pair<>:
> 
>     for( auto it : my_unordered_map )
> 
> 
> But I don’t like it in other cases.  This reduces readability for me:
> 
>     auto pos = pin->GetPosition();
> 
> 
> However, I’m just one voice, and the idea of when something is a “stupid
> template thing” and when it isn’t is admittedly pretty ill-defined.
> 
> How do others feel?
> 
> Cheers,
> Jeff.

I am thinking auto should be not used for basic types (bool, int ...)
and very usual types (wxPoint, wxString, std::string) because it
obfuscate these types without benefit.
Of course, obfuscation depends of the context.

But I agree it is really very useful for iterators.

-- 
Jean-Pierre CHARRAS


Follow ups

References