Annoying thing about auto ref function template

Yuxuan Shui via Digitalmars-d digitalmars-d at puremagic.com
Tue Mar 21 02:27:55 PDT 2017


On Tuesday, 21 March 2017 at 01:10:38 UTC, Jonathan M Davis wrote:
> On Monday, March 20, 2017 22:14:37 Yuxuan Shui via 
> Digitalmars-d wrote:
>> On Monday, 20 March 2017 at 21:53:47 UTC, Jonathan M Davis 
>> wrote:
>> > [...]
>>
>> Makes sense...
>>
>> OK, attempt 2: how about support implicit partial application 
>> for templates?
>
> Well, you can do something like
>
> template foo(T)
> {
>     auto foo()(auto ref T t)
>     {
>         return t;
>     }
> }
>
> void main()
> {
>     alias f = foo!int;
>     auto a = f(42);
> }
>
> and then foo!int, but you're not going to get a function 
> pointer out of it, since for that, you need to instantiate the 
> inner function template. It does give partial instantiation 
> though.
>
> - Jonathan M Davis

This is looks doable. Can we do this for all auto ref functions 
in phobos?


More information about the Digitalmars-d mailing list