About foreach loops

Simen Kjaeraas simen.kjaras at gmail.com
Thu Jun 16 08:26:24 PDT 2011


On Wed, 15 Jun 2011 22:40:24 +0200, bearophile <bearophileHUGS at lycos.com>  
wrote:

> Don:
>
>> The alternative would be to create __iterator1234 as const, and then
>> cast away const in the ++ step. Ugly, but would eliminate the
>> performance cost for structs.
>
> Isn't it undefined in D to modify a const?

I believe this is only because the source may be immutable, and thus
reside in ROM or otherwise be optimized away in places. Casting away
const for a variable you have full control of, should not pose
problems.

-- 
   Simen


More information about the Digitalmars-d mailing list