Get address of overloaded function
Chris Nicholson-Sauls
ibisbasenji at gmail.com
Sat Feb 24 10:42:01 PST 2007
Jarrett Billingsley wrote:
> "Frank Benoit (keinfarbton)" <benoit at tionex.removethispart.de> wrote in
> message news:erpk4o$1oom$1 at digitalmars.com...
>> I want to assign a function ptr to a void* variable.
>>
>> There are no compile error in case the function is a overloaded one. Is
>> this a bug?
>>
>> How to select the correct function? I tried a cast, and it seams to work.
>>
>> void fnc(){}
>> void fnc(int a ){}
>>
>> void * ptr = cast(void*)cast( void function( int )) & fnc;
>
> Yes, that does seem to choose the (int) overload. Although what's really
> odd is that getting the address of fnc without any cast before it gets the
> address of the overload that was defined first. Personally I think it
> should be an error, as it's ambiguous..
>
>
And now one of the classic proposals, once again. :)
void* ptr = cast(void*) &fnc(int) ;
So nice, so concise.
-- Chris Nicholson-Sauls
More information about the Digitalmars-d
mailing list