Should be easy

Saaa empty at needmail.com
Tue Jun 16 11:43:57 PDT 2009


template BaseType(T: T[]) { alias BaseType!(T) BaseType; }
template BaseType(T) { alias T BaseType; }

> Otherwise, you need indexAssign:
>
> void indexAssign(TArray : TArray[])(TArray array, BaseType!(TArray) value, 
> int[] indices...)
> {
> static if (is (typeof (array[0]) == typeof(value))
> {
> array[indices[0]] = value;
> }
> else
> {
> indexAssign(array[indices[0]], value, indices[1..$]);
> }
> }

int[][][] a;
a.length = 3;
a[1].length = 3;
a[1][2].length = 3;

int[3] index;
index[0]=1;
index[1]=2;
index[2]=3;

int value = 10;

writefln(BaseType!(value).stringof);
// template instance BaseType!(value) does not match any template 
declaration

indexAssign(a,value,index);
// template ddata.main.indexAssign(T : T[]) does not match any template 
declaration
// template ddata.main.indexAssign(T : T[]) cannot deduce template function 
from argument types !()(int[][][],int,int[3u])


What am I doing wrong this time..?
just when I though I understood the code a bit :) 




More information about the Digitalmars-d-learn mailing list