mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-07-27 01:25:21 +02:00
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.
This commit is contained in:
30
tests/mini/tupleval.d
Normal file
30
tests/mini/tupleval.d
Normal file
@@ -0,0 +1,30 @@
|
||||
module foo;
|
||||
|
||||
template ParameterTupleOf( Fn )
|
||||
{
|
||||
static if( is( Fn Params == function ) )
|
||||
alias Params ParameterTupleOf;
|
||||
else static if( is( Fn Params == delegate ) )
|
||||
alias ParameterTupleOf!(Params) ParameterTupleOf;
|
||||
else static if( is( Fn Params == Params* ) )
|
||||
alias ParameterTupleOf!(Params) ParameterTupleOf;
|
||||
else
|
||||
static assert( false, "Argument has no parameters." );
|
||||
}
|
||||
|
||||
struct S
|
||||
{
|
||||
int opApply(T)(T dg)
|
||||
{
|
||||
alias ParameterTupleOf!(T) U;
|
||||
U u;
|
||||
u[0] = 1;
|
||||
u[1] = 2;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
foreach(int x, int y; S()){}
|
||||
}
|
||||
Reference in New Issue
Block a user