Different types with auto

Regan Heath regan at netmail.co.nz
Fri Mar 18 09:11:52 PDT 2011


On Fri, 18 Mar 2011 00:30:30 -0000, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:

> On 3/17/11 7:27 PM, KennyTM~ wrote:
>> On Mar 18, 11 04:17, Jason E. Aten wrote:
>>>> auto x1=1., x2=2., x3=3., x4=4., x5=5, x6=6.;
>>>
>>> If the coder wanted them to all be doubles, it's easy to require that  
>>> by
>>> just saying so, and then even x5 will be a double.
>>>
>>> double x1=1., x2=2, ...
>>>
>>> So it seems to me that auto does exactly what you asked it to here,  
>>> and I
>>> actually prefer this behavior for conciseness and expressiveness sake.
>>>
>>
>> auto x1 = templateFunctionWithComplicatedReturnType("a"),
>> x2 = templateFunctionWithComplicatedReturnType("b"),
>> x3 = templateFunctionWithComplicatedReturnType('c'),
>> x4 = templateFunctionWithComplicatedReturnType("d");
>
> Yah, not sure what would ever be bad about that.

Nor is there anything bad about this:

auto x1 = templateFunctionWithComplicatedReturnType("a");
auto x2 = templateFunctionWithComplicatedReturnType("b");
auto x3 = templateFunctionWithComplicatedReturnType('c');
auto x4 = templateFunctionWithComplicatedReturnType("d");

in fact, it lines up neatly so I prefer it :P

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/


More information about the Digitalmars-d mailing list