Compile time iota

Jakob Ovrum via Digitalmars-d digitalmars-d at puremagic.com
Thu Jan 22 18:00:25 PST 2015


On Wednesday, 21 January 2015 at 18:26:11 UTC, H. S. Teoh via 
Digitalmars-d wrote:
> 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

There was a PR to make `staticIota` public, but it was superceded 
by a more general `toTypeTuple`[1] that works with any CTFE-able 
range, including the titular `iota`. It too was eventually 
closed, this time because of the whole naming situation. It's an 
unfortunate situation, but now that we've come this far, I think 
the way forward is to go ahead and try to get the std.meta rename 
merged.

[1] https://github.com/D-Programming-Language/phobos/pull/1472


More information about the Digitalmars-d mailing list