Error: variable i cannot be read at compile time

Vino vino.bheeman at hotmail.com
Fri Jan 5 09:09:00 UTC 2018


On Thursday, 4 January 2018 at 18:49:21 UTC, Ali Çehreli wrote:
> On 01/04/2018 08:51 AM, Vino wrote:
>
> > auto read () {
> [...]
> > return tuple(Ucol1, Ucol2, Ucol3, rSize);
> > }
>
> read() returns a tuple of values of different types.
>
> > for(int i = 0; i < Size; i++) {
> > typeof(read()[i]) Datacol;
>
> typeof is a compile-time expression but there cannot be a 
> consistent result to that expression when i is not known at 
> compile-time.
>
> You might try using a 'static foreach' but this time Size is 
> not a compile-time expression:
>
>     static foreach(i; 0 .. Size) {
>         typeof(read()[i]) Datacol;
>
> Error: variable Size cannot be read at compile time
>
> Ali

Hi Ali,

   Thank you very much, can you suggest the best way around this 
issue.

From,
Vino.B


More information about the Digitalmars-d-learn mailing list