Tuple slicing fails

Bill Baxter dnewsgroup at billbaxter.com
Mon May 14 16:38:13 PDT 2007


Erik Baklund wrote:
> Hi,
> 
> I am trying to understand tuples.
> Does anybody know why line 11 below fail?
> Is it conceptually wrong or is it a compiler glitch?
> 
> Erik
> 
>  1	import std.stdio;
>  2
>  3
>  4	template Tuple1(E...) 
>  5	{ 
>  6		alias E Tuple1; // Works
>  7	}	
>  8
>  9	template Tuple2(E...) 
> 10	{ 
> 11		alias E[0..length] Tuple2;  // Sematicly the same (?) but fails
> 12	}	
> 13
> 14	int main (char[][] args)
> 15	{
> 16		writefln(Tuple1!(3, 7L, 6.8));   
> 17		writefln(Tuple2!(3, 7L, 6.8));   
> 18
> 19		return 0;
> 20	}
> 
> 
> a.d(11): tuple E is used as a type
> a.d(11): Error: can only slice tuple types, not void
> a.d(17): template instance a.Tuple2!(3,7L,6.8) error instantiating

I think your DMD is too old.  Works fine here with v1.014.  There were a 
number of problems like that in older versions of dmd.

--bb


More information about the Digitalmars-d-learn mailing list