Forwarding calls to objects of another type

Johan Fjeldtvedt via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Apr 19 14:26:44 PDT 2017


On Tuesday, 11 April 2017 at 02:01:19 UTC, Nicholas Wilson wrote:
> On Monday, 10 April 2017 at 21:27:34 UTC, Basile B. wrote:
>>> 2) This is about the reduce templates. As I've commented, I 
>>> can't use a template lambda with reduce, but I can use a 
>>> lambda taking ints as arguments. Why is this? The error 
>>> message I get when using the template lambda is:
>>>
>>> "template instance reduce!((a, b) => a + b) cannot use local 
>>> '__lambda1' as parameter to non-global template reduce(alias 
>>> fun)()"
>>
>> No idea for this.
>
> The use of the global identity template will fix this:
>
> see 
> https://blog.thecybershadow.net/2015/04/28/the-amazing-template-that-does-nothing/

Thanks, that did work. I think I understand the point about UFCS 
lookup rules, but it still seems strange (it was at least 
surprising) that I couldn't use the template (a, b) => a + b in 
place of (int a, int b) => a + b.


More information about the Digitalmars-d-learn mailing list