Address of overloaded functions

Artur Skawina art.08.09 at gmail.com
Wed Jul 3 08:09:51 PDT 2013


On 07/03/13 17:03, Artur Skawina wrote:
> On 07/03/13 16:52, John Colvin wrote:
>> Is there any way to take the address of any of an overloaded set of functions?
>>
>> import std.stdio;
>>
>> void foo(int a){ writeln("overload int"); }
>> void foo(long b){ writeln("overload long"); }
>>
>> void main()
>> {
>>     auto b = &foo; //ambiguous => error
>>     b(2); //valid for either overload
>> }
> 
>     void function(long) b = &foo;

And if you meant for the overload resolution to happen at call-time,
that's obviously not directly possible - there's no address of a /set/
of functions. You can use an alias, though:

    alias b = foo;

artur



More information about the Digitalmars-d-learn mailing list