On 03/21/2017 04:09 PM, StarGrazer wrote:
On Tuesday, 21 March 2017 at 15:01:43 UTC, ag0aep6g wrote:
On 03/20/2017 05:55 PM, StarGrazer wrote:
typeof(&method) fails unless method is static. Says & requires this.

Works for me:

----
class C
{
    void method() {}
    typeof(&method) x;
}
typeof(&C.method) y;
----

Tested with dmd 2.073.2.

Yes, but you changed it. I didn't have C. Initially this wasn't a problem.

I just filled the blanks you left. Note that my snippet still includes `typeof(&method)` verbatim. The added `typeof(&C.method)` is just bonus.

If you have code that fails unexpectedly, please feel free to post it.

[...]
You are making assumptions... my functions where static and I was trying
to convert them to non-static methods and this is where the trouble
started creeping in.

Going from static to non-static means going from `function` to `delegate`. I don't think there's a way around that. You can get a `function` type from a method, but it won't be useful with actual methods.

Reply via email to