Hello,
I'm trying to create a dictionary of templated function pointers. The functions should return bool
and take a differently-typed dynamics arrays T[]
as an argument. Based on my understanding of the docs, I've made two failed attempts:
Attempt 1:
https://github.com/PhilippeSigaud/D-templates-tutorial/blob/master/D-templates-tutorial.md
template ArrArgs(T){
alias bool function(T[])[string] FuncDict; // compiles
FuncDict lookup; // This compiles but name `lookup` is not understood
}
// Compiler does not allow me to declare `FuncDict lookup;` here
void main(){
lookup["foo"] = function bool( string[] args ){ return true; }; // undefined identifier `lookup`
}
Attempt 2:
https://dlang.org/library/std/meta/alias.html
alias FuncDict = bool function(T[])[string]; // undefined identifier `T`
FuncDict lookup;
void main(){
lookup["foo"] = function bool( string[] args ){ return true; };
}
I'm unsure of what feature or structure of D will accomplish this.
An example or a link to an example of associated arrays of templated function pointers would help me a great deal.