auto
BCS
BCS at pathlink.com
Wed Jun 20 19:10:08 PDT 2007
Ary Manzana wrote:
> Derek Parnell escribió:
>
>> On Wed, 20 Jun 2007 14:20:43 +0200, Hoenir wrote:
>>
>>> I still can't get the purpose of "auto".
>>> I know it makes it possible to e.g. write "auto y = 4u;" but why not
>>> just "uint y = 4;"?
>>
>>
>> auto y = someFunc(); // What type is it now?
>>
>>
>
> // What can you do with y now, if you don't know the type?
whatever you want
auto z = y * 2;
auto x = z*y;
return x + y + z;
With a little care and a working knowledge of the typing rules of
expressions you can get a lot done without ever using a actual type.
This is of a lot of use if you are doing template code where you really
can't known the type until compile time.
More information about the Digitalmars-d-learn
mailing list