Function pointer argument to function template
Tom S
h3r3tic at remove.mat.uni.torun.pl
Tue May 30 14:08:33 PDT 2006
Hey there :)
I came up with this:
----
import std.stdio;
template Deref(T) {
alias typeof(*T) Deref;
}
template RetType(T) {
static if (is(Deref!(T) U == function)) {
alias U RetType;
} else static assert (false);
}
template Bar(T, U=RetType!(T)) {
U Bar(T t) {
writefln(typeid(U));
// do something :P
return U.init;
}
}
cfloat func(int a, float b) {
return 1.f + 0i;
}
void main() {
writefln(Bar(&func));
}
--
Tomasz Stachowiak /+ a.k.a. h3r3tic +/
More information about the Digitalmars-d
mailing list