Tuple slicing fails
Erik Baklund
ebaklund at hotmail.com
Mon May 14 12:52:40 PDT 2007
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
More information about the Digitalmars-d-learn
mailing list