Access template parameters at runtime

Vladimir Panteleev vladimir at thecybershadow.net
Fri Aug 10 07:10:01 PDT 2012


On Friday, 10 August 2012 at 14:05:16 UTC, Henning Pohl wrote:
> Oups, sorry, imagine there isn't one.
>
> So the error is: variable idx cannot be read at compile time.

You can't index a tuple during compilation. You need to use an 
array:

struct SomeStruct(alias integers) {
     int opIndex(size_t idx) {
         return integers[idx];
     }
}

alias SomeStruct!([1, 2, 3]) ss;



More information about the Digitalmars-d mailing list