array of delegates
David Skluzacek via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Apr 13 22:54:38 PDT 2016
So, that message is a pretty cryptic, but the problem there is
that map does its thing at runtime, but partial is a template and
must be instantiated at compile time.
Instead you can use std.meta.staticMap, by doing something like
this:
----
void main()
{
import std.stdio;
import std.functional;
import std.meta;
AA aa = new AA();
int delegate(int, Props) sg;
sg = &aa.Foo;
template partialSG(alias a)
{
alias partialSG = partial!(sg, a);
}
alias indarr = AliasSeq!(0, 1, 2, 3, 4);
alias funs = staticMap!(partialSG, indarr);
foreach (fun; funs)
{
writeln( fun(Props.p1) );
writeln( fun(Props.p2) );
}
}
More information about the Digitalmars-d-learn
mailing list