Language proposal: auto in loop conditions

FeepingCreature default_357-line at yahoo.de
Tue Jul 13 08:46:46 PDT 2010


On 13.07.2010 06:38, Andrei Alexandrescu wrote:
> Yah, truth be told getNext won't win a prize for brevity. You need to
> define both a variable and a pointer to use it:
> 
> T meh;
> T * neh;
> while ((neh = getNext(r, meh))) {
>    ... process *neh ...
> }
> 

One way to make this slightly easier would be allowing auto in loop bodies, same as it works in if - ie.

T meh;
while (auto neh = getNext(r, meh)) { }


More information about the Digitalmars-d mailing list