Access template parameters at runtime

Henning Pohl henning at still-hidden.de
Fri Aug 10 07:05:15 PDT 2012


On Friday, 10 August 2012 at 14:02:08 UTC, Andrei Alexandrescu 
wrote:
> On 8/10/12 9:55 AM, Henning Pohl wrote:
>> A struct is meant to take only integers as parameters:
>>
>> struct SomeStruct(intergers...) {
>> int opIndex(size_t idx) /* ... */ {
>> return integers[idx]; // Error ...
>> }
>> }
>>
>> alias SomeStruct!(1, 2, 3) ss;
>>
>>
>> But it results in:
>> Error: undefined identifier integers, did you mean tuple 
>> intergers?
>>
>>
>> How can this problem be solved?
>
> By fixing the typo?
>
> Andrei

Oups, sorry, imagine there isn't one.

So the error is: variable idx cannot be read at compile time.


More information about the Digitalmars-d mailing list