Unrolling loops

BCS ao at pathlink.com
Mon Mar 10 17:28:45 PDT 2008


Reply to Jarrett,

> "Simen Kjaeraas" <simen.kjaras at gmail.com> wrote in message
> news:fr4ec8$kd3$1 at digitalmars.com...
> 
>> Is it possible to unroll loops in D2.0? I have a templated struct
>> with a static array with length set through a template parameter.
>> Does that get automatically unrolled with 4 elements (I doubt it), do
>> I have to use some magic string mixin, or could I fix this with
>> tuples and their automatic loop unrolling?
>> 
>> Actually, that latter one is worth a question of its own. Can I
>> convert a static array into a tuplem and if so, how?
>> 
>> -- Simen
>> 
> In the presentation Walter and Andrei gave at the D con last year,
> they presented a "static loop" feature that would unroll the loop at
> compile time.
> 
> static foreach(blah; something)
> {
> //...
> }
> So it's "in the works" for D2, I guess, but who knows when it'll
> actually be implemented.
> 

you can do it with tuple a foreach, but it's not very clean




More information about the Digitalmars-d-learn mailing list