On Thursday, 14 April 2016 at 05:54:38 UTC, David Skluzacek wrote:
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) );
}
}
Ah, ok... so, it was my mistake due to runtime <-> compile time
templates. Thanks.
But, this would help, only if I know the total amount of my
elements at compile time. Say, the length of the indarr would be
known.
What if I don't have this information? In reality, this
information is already known for the constructors of my classes.
But it seems very strange to me, to let the user recompile the
program each time with some compiler flag in order to deliver
this parameter a step prior to this.