On Sunday, 20 November 2016 at 11:23:37 UTC, Nicholas Wilson
wrote:
On Sunday, 20 November 2016 at 11:19:24 UTC, Tofu Ninja wrote:
I feel like this should be simple but I can't seem to figure
it out. How do I declare a function to have the same call
signature as another function/callable type?
Like if I have:
alias Sig = int function(int x, int y);
How do I define a function such that it will have the same
call signature as Sig? How do I take into account all the
extra stuff that can go into a function signature like the
argument attributes and the return type attributes etc.?
Another way to phrase this question would be, how do I pass a
function signature into a template and actually define
functions with it?
Related question, if I have Sig, how would I define DeltaSig
to be exactly the same as Sig but with an extra parameter at
the start or end of the parameter list?
Thanks :)
import std.traits;
ReturnType!Sig func(Parameters!Sig args)
{
//...
}
This does not seem to account for return type attributes or
function attributes. Eg:
alias Sig = ref int function() @nogc;
ReturnType!Sig func(Parameters!Sig args) {
// func is missing ref on return type and is not @nogc
static int g;
return g;
}
How should I account for these things?