How to distinguish a delegate from a function?

Moritz Warning moritzwarning at web.de
Sat Jul 12 14:11:46 PDT 2008


On Sun, 13 Jul 2008 06:03:53 +0900, Bill Baxter wrote:

> Moritz Warning wrote:
>> I try to check (at compile time) if an expression need to be called
>> with a context pointer or without.
>> 
>> E.g.: I want to tell the difference between A.foo (no context pointer
>> needed) and A.bar.
>> 
>> class A
>> {
>>    static void foo() {}
>>    void bar() {}
>> }
>> 
>> Any ideas?
> 
> I think these work:
> static if(is(xxx == function))
> static if(is(xxx == delegate))
> 
> --bb

Doesn't seem to work.
Here are some of my tries (all evaluate to false):

static if (is(Foo.get == delegate))
static if (is(Foo.init.get == delegate))
static if (is(typeof(Foo.get) == delegate))
static if (is(typeof(&Foo.get) == delegate))



More information about the Digitalmars-d mailing list