On 01/09/2015 10:42 AM, Jonathan Marler wrote:
import std.stdio;
import std.typecons;
void main()
{
   alias TL = Tuple!(int, long, float);
   foreach (i, T; TL)
     writefln("TL[%d] = %s", i, typeid(T));
}

Why is this not working?

D:\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(419): Error: need
'this' for '_expand_field_0' of type 'int'
D:\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(419): Error: need
'this' for '_expand_field_1' of type 'long'
D:\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(419): Error: need
'this' for '_expand_field_2' of type 'float'

Tried to compile using dmd 2.066 and dmd 2.067.  Code taken directly
from dlang website here (http://dlang.org/tuple.html). Thanks.

Broken documentation presumable because the feature changed later on. The code works if you we std.typetuple.TypeTuple:

import std.stdio;
import std.typetuple;

void main()
{
  alias TL = TypeTuple!(int, long, float);
  foreach (i, T; TL)
      writefln("TL[%d] = %s", i, typeid(T));
}

Ali

  • Tuples not working? Jonathan Marler via Digitalmars-d-learn
    • Re: Tuples not working? Ali Çehreli via Digitalmars-d-learn

Reply via email to