Problem with templates
BCS
ao at pathlink.com
Mon Jul 7 10:30:29 PDT 2008
Reply to Sean,
>> It can't. Delegates and functions currently have different calling
>> conventions and the compiler cannot automatically convert one to the
>> other. Was this just intuition or did you read that it would
>> somewhere?
>>
> Take this example:
>
[...]
> void main()
> {
> int plus(int x, int y, int z)
> {
> return x + y + z;
> }
> auto plus_two = Curry(&plus, 2);
>
> Notice how the function Curry accepts a delegate, but a function
> pointer is actually passed in. I have personally re-written this
> function to take advantage of D2 closures and it worked perfectly
> fine.
>
taking the address of a (non static) nested functions generates a delegate,
not a function pointer.
More information about the Digitalmars-d-learn
mailing list