Compile time iota

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Wed Jan 21 10:23:54 PST 2015


On Wed, Jan 21, 2015 at 07:14:09PM +0100, zeljkog via Digitalmars-d wrote:
> 
> Maybe something like this can be added to Fobos:
> 
> template Iota(int start, int stop, int step = 1){
>     template tuple(T...){
>         alias tuple = T;
>     }
>     static if(start < stop)
>         alias Iota = tuple!(start, Iota!(start + step, stop, step));
>     else
>         alias Iota = tuple!();
> }

This is actually already implemented as std.typecons.staticIota, but
it's currently undocumented and restricted to only Phobos code. I'm not
sure why it was decided not to make it public, but if you file an
enhancement request, the devs can look at it and decide if it's worth
making it public.


T

-- 
Life is unfair. Ask too much from it, and it may decide you don't deserve what you have now either.


More information about the Digitalmars-d mailing list