Boost logo

Boost :

From: John Torjo (john.lists_at_[hidden])
Date: 2003-11-23 19:02:38


>>Just to stick my two cents in why bother with a ++
>>operator in the for loop the increment is implied
>>
>>so you could write something like the following
>>for (; r; )
>>{
>> *r;
>>}
>>
>>increment and test makes more sense for a range object
>> within the of a loop. Right :-)
>
>
> I disagree.
> Code should not be a short as possible, it should be as meaningful as
> possible.
> The intent is obvious with the idiom "for(; r; ++r)" and it should be.
>

Indeed ;)
Also, what if you need to dereference twice?

Example:
for ( ; r; ++r) {
    r->first_name = r->last_name; // dereferencing twice
}

Best,
John


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk