std.functional:partial - disambiguating templated functions
John Colvin via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Oct 4 09:37:32 PDT 2015
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?
> I have:
>
> alias
> bars=partial!(slurpBars!BarType,filename,startDate,endDate);
>
> where there are two overloads of slurpBars:
>
> SomeBar[] slurpBars(SomeBar)(string filename,string
> datasetName, typeof(SomeBar.date) startDate,
> typeof(SomeBar.date) endDate)
> SomeBar[] slurpBars(SomeBar)(hid_t filehandle,string
> datasetName, typeof(SomeBar.date) startDate,
> typeof(SomeBar.date) endDate)
>
> And I receive the following error:
> Error: template kprop.marketdata.retrievebars.slurpBars
> matches more than one template declaration:
>
> Thanks.
>
>
> Laeeth.
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.
More information about the Digitalmars-d-learn
mailing list