Modify Function Pointer to Take Additional Parameters
Nicholas Wilson via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Feb 19 03:26:56 PST 2016
On Friday, 19 February 2016 at 05:41:01 UTC, jmh530 wrote:
> I'm trying to write a function that will adjust the parameters
> of a function pointer.
>
I think the problem is that it defaults to a delegate not that it
cannot be one
does clarifying this to the compiler work
Like
> alias fp1 = int function(int x);
> alias fp2 = int function(int x, int y);
>
> auto foo(T)(T f)
> {
> static if (is(T == fp2))
> return f;
> else static if (is(T == fp1))
> {
> return int function(int x, int y) => f(x);
> }
> else
> return 0;
> }
>
?
More information about the Digitalmars-d-learn
mailing list