Templating with Function Pointers?

Maxime Chevalier-Boisvert maximechevalierb at gmail.com
Wed Dec 11 18:43:45 PST 2013


I'd like to know if it's possible to create a templated function 
that takes a function pointer as an argument, and uses static ifs 
to generate different behaviors based on the type signature of 
the function pointer.

More specifically, I want to create code generation functions for 
my JIT compiler, and template them based on a pointer to a 
function that implements the semantics of the operation being 
jitted. Not all of these operations take the same arguments, so 
I'd like to be able to template and generate different machine 
code.

Is it possible to template based on a function pointer argument? 
If so, is it possible to use static ifs to know the return type 
or the argument types of the function pointer's signature, as 
well as how many arguments it takes?


More information about the Digitalmars-d-learn mailing list