comparison tests/mini/tupleval.d @ 648:8d850fa25713

Fix VarDecls for tuples. Closes #99. I've implemented it this way since it doesn't require any changes in the frontend. However, I think having TypeTuple expressed as LLVM struct types would make much more sense and open the door to tuple lvalues.
author Christian Kamm <kamm incasoftware de>
date Sun, 05 Oct 2008 11:47:47 +0200
parents
children
comparison
equal deleted inserted replaced
646:51c4d1a64da6 648:8d850fa25713
1 module foo;
2
3 template ParameterTupleOf( Fn )
4 {
5 static if( is( Fn Params == function ) )
6 alias Params ParameterTupleOf;
7 else static if( is( Fn Params == delegate ) )
8 alias ParameterTupleOf!(Params) ParameterTupleOf;
9 else static if( is( Fn Params == Params* ) )
10 alias ParameterTupleOf!(Params) ParameterTupleOf;
11 else
12 static assert( false, "Argument has no parameters." );
13 }
14
15 struct S
16 {
17 int opApply(T)(T dg)
18 {
19 alias ParameterTupleOf!(T) U;
20 U u;
21 u[0] = 1;
22 u[1] = 2;
23 return 0;
24 }
25 }
26
27 void main()
28 {
29 foreach(int x, int y; S()){}
30 }