digitalmars.D.learn - Tuples not working?
- Jonathan Marler (18/18) Jan 09 2015 import std.stdio;
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (12/29) Jan 09 2015 Broken documentation presumable because the feature changed later on.
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.
Jan 09 2015
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
Jan 09 2015