enum tuple subscript as template parameter => Tuple(A(0)) must be an array or pointer type, not Tuple!(A)

bastien penavayre via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun May 7 20:23:20 PDT 2017


Hi,

I'm having a bit of an issue here and the compiler is not really 
explicit.
Here's the code:

import std.typecons;

struct A { int i; }

void main()
{
    enum t = tuple(A());
    f!(t[0].i); //Error: Tuple(A(0)) must be an array or pointer 
type, not Tuple!(A)
    f!((&t[0]).i) //Ok
    enum v = t[0];
    f!(v.i); //Error: template instance f!(i) does not match 
template declaration f(int T)()
    f!((v.i)); //Ok
}

void f(int T)() {}


More information about the Digitalmars-d-learn mailing list