Template argument deduction from a function call question

Dzugaru via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 1 11:20:40 PDT 2015


> a)
> isn't this almost, if not exactly, the same as 
> std.algorithm.reduce?
>
> b)
> you can write nice things like this:
> auto min = [2,4,1,3,5].aggregate!((a,  b) => a < b ? a : 
> b)(int.max);
>
> c)
> the deduction failure looks like a bug to me, perhaps there is 
> a good reason why it can't work in the general case.

a) Had a look at std.algorithm.reduce, looks like this is what I 
did, but there are 2 overloads inside a template block instead of 
parameter with a default value (also less strictly typed):

template reduce(fun...) {
auto reduce(R)(R r)
auto reduce(S, R)(S seed, R r)
}

The code there though is mindboggling :)

b) Thanks, forgot about that



More information about the Digitalmars-d mailing list