ReturnType and overloaded functions

Yuxuan Shui via Digitalmars-d digitalmars-d at puremagic.com
Sat Jun 13 01:51:43 PDT 2015


On Saturday, 13 June 2015 at 05:14:00 UTC, Kenji Hara wrote:
> 2015-06-13 9:29 GMT+09:00 Idan Arye via Digitalmars-d <
> digitalmars-d at puremagic.com>:
>
>> On Friday, 12 June 2015 at 23:26:00 UTC, Yuxuan Shui wrote:
>>
>>> When there are multiple overloaded functions, whose return 
>>> type will I
>>> get when I use ReturnType? Is there a way I could choose a 
>>> specific
>>> function by its parameter types?
>>>
>>
>> The return type of the first declared one:
>> http://dpaste.dzfl.pl/f448ec624592
>>
>
> That's definitely a bug in current dmd. ReturnType should make 
> error when
> overloaded function symbol is given.
>
> To pick up one of the overloaded functions, you can use
> __traits(getOverloads).
>
> Kenji Hara

It's kind of pointless to pick any one of the overloads. It would 
be convenient if a template exists to help us pick a overload by 
matching its parameter type.

That being said, the solution given earlier in this thread seems 
to work, I just wonder if there're any caveats.


More information about the Digitalmars-d mailing list