Mixin and function template?
renoX
renosky at free.fr
Wed Feb 28 01:49:47 PST 2007
Hello,
I have a template which contain a single function:
template sputf(A...)
{
char[] call()
{
auto fd=std.c.stdio.fopen("tmp_file", "w+");
mixin(`fwritef(fd,`~Fmt!(A)~`);`);
std.c.stdio.fclose(fd);
auto res = cast(char[])read("tmp_file");
return res;
}
}
At the call site, I have to do the following:
mixin sputf!("%d{x}") P1;
res = P1.call();
which is quite ugly, so I'd like to convert the code in a 'function template' but when I do this, I don't manage to call the function without failure..
Does someone knows how to do it?
Regards,
renoX
More information about the Digitalmars-d-learn
mailing list