std.functional:partial - disambiguating templated functions

John Colvin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Oct 4 11:24:06 PDT 2015


On Sunday, 4 October 2015 at 18:08:55 UTC, Laeeth Isharc wrote:
> On Sunday, 4 October 2015 at 17:17:14 UTC, Laeeth Isharc wrote:
>> On Sunday, 4 October 2015 at 16:37:34 UTC, John Colvin wrote:
>>> On Sunday, 4 October 2015 at 15:45:55 UTC, Laeeth Isharc 
>>> wrote:
>>>> How do I persuade partial to tie itself to the appropriate 
>>>> overload?
>> ---
>>> As far as I can see std.functional.partial only does one 
>>> argument at a time.
>>>
>>> bars=partial!(partial!(partial!(slurpBars!BarType, filename), 
>>> startDate), endDate);
>>>
>>> or maybe, I'm not sure, but maybe you can do:
>>>
>>> bars=partial!(slurpBars!BarType, AliasSeq!(filename, 
>>> startDate, endDate));
>>>
>>> If you find you really need to manually mess with overloads, 
>>> use http://dlang.org/traits.html#getOverloads. You may have 
>>> to wrap it in AliasSeq in some situations due to 
>>> grammar/parser constraints.
>> fwiw - still doesn't work (whether I use alias or auto, trying 
>> each of your solutions).  I'll look at getOverloads.
>
> How do I distinguish between two overloads that return the same 
> type but have different arguments?  It looks like getOverloads 
> only deals with cases where the return type is different, 
> judging by the docs.

getOverloads should give you all the overloads of a function, 
whether they return the same or different types.  The example in 
the docs just happens to have different types.

In general, return types are not considered when talking about 
overloads. For example, two functions that take the same 
arguments but have different return types are not overloaded, 
they are in conflict.


More information about the Digitalmars-d-learn mailing list