Tuple [] operator

Philippe Sigaud philippe.sigaud at gmail.com
Mon Aug 8 12:34:28 PDT 2011


Hi Chris,

> import std.typecons;
> void main() {
> auto x = 1;
> Tuple!(int,short) a;
> a[0] = 1;
> a[x] = 2;
> }
>
> If I use a value instead of a variable ie. a[1] = 2; it compiles fine.

The index need to be a compile-time constant, you cannot index a tuple
with a runtime value.
Try using

enum x = 1;


Philippe


More information about the Digitalmars-d-learn mailing list