template tupIndexToRange(alias Tup, Indices...){
import std.meta;
static if(Indicies.length == 0){
alias tupIndexToRange = AliasSeq!();
}
else{
alias tupIndexToRange = AliasSeq!(Tup[ Indices[0] ][], tupIndexToRange!(Tup,Indices[1..$]));
}
}
void main{
alias Integrals = AliasSeq!(Array!int, Array!float, Array!double);
Integrals integrals;
alias IntegralRange = tupIndexToRange!(integrals,0,1);
}
我想要實現這樣的過濾容器與指數
auto range = zip(tupIndexToRange!(integrals,0,1));
我認爲主要的問題是,Tup[ Indices[0] ]
不工作,我一個元組應該已經擴展到這個AliasSeq!(itegrals[0][],integrals[1][]);
source/app.d(108,22): Error: inout method std.container.array.Array!int.Array.opIndex is not callable using a mutable object source/app.d(108,22): Error: inout method std.container.array.Array!int.Array.opIndex is not callable using a mutable object source/app.d(108,22): Error: only one index allowed to index int source/app.d(108,22): Error: only one index allowed to index int source/app.d(108,54): Error: template instance app.main.tupIndex!(__integrals_field_0, 1) error instantiating source/app.d(108,54): instantiated from here: tupIndex!(__integrals_field_0, 0, 1) source/app.d(108,54):
instantiated from here: tupIndex!(__integrals_field_0, __integrals_field_2, 0, 1) source/app.d(155,3): instantiated from here: tupIndex!(__integrals_field_0, __integrals_field_1, __integrals_field_2, 0, 1) dmd failed with exit code 1
這大概是我想達到
什麼但不是auto range = zip(tuple(integrals[0][],integrals[1][]).expand);
我希望它是通用auto range = zip(tupIndexToRange!(integrals, AliasSeq!(0, 1)).expand);
也許我需要用混入?