Modify Function Pointer to Take Additional Parameters
jmh530 via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Feb 19 06:55:42 PST 2016
On Friday, 19 February 2016 at 11:26:56 UTC, Nicholas Wilson
wrote:
>
> 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;
>> }
>>
> ?
This code doesn't compile for me. I have to adjust it to
return function int(int x, int y) => f(x);
and then it complains that it's a delegate.
More information about the Digitalmars-d-learn
mailing list