indexing a tuple containing a struct strange result

cal callumenator at gmail.com
Sun Jun 23 18:22:08 PDT 2013


What is going on here?

import std.stdio, std.typecons;

struct S
{
     int x;
     Tuple!(S) foo() { return tuple(this); }
}

void main()
{
     S s;
     s.x = 8;
     writeln((s.foo()));     //output: Tuple!(S)(S(8))
     writeln((s.foo())[0]);  //output: S(0)
}


More information about the Digitalmars-d-learn mailing list