auto

Trass3r un at known.com
Thu Nov 24 13:09:01 PST 2011


> is there any performance gap using auto instead of int or other
> type? For example
>
> int[] ar1 = new int[1000];
> auto[] ar2 = new int[1000];
>
> are these equivalent by a perfomance point of view?

Well the runtime performance is equal but of course compilation takes  
slightly longer since it has to deduce the type first.
But in general you should only use auto if it doesn't make your code  
harder to understand (e.g. auto x =  
funcThatDoesCrazyShitYouCantGuessFromTheName(); // so, what's the type of  
x???).

Also it's 'auto ar2' instead of 'auto[] ar2'.


More information about the Digitalmars-d-learn mailing list