On 04/01/2015 11:15 AM, John Colvin wrote:

>> Instead of using
>> ElementType!S in the parameter list, introduce a third one (E), which
>> you check in the template constraint:
>>
>> ElementType!S aggregate(alias func, S, E)(S list, E accum = E.init)
>> if(is (E == ElementType!S) &&                   // <-- ADDED
>>     is(typeof(func(accum, accum)) == typeof(accum))) {
>>         // ...
>> }
>>
>> Now it works.
>>
>> Ali
>
> Great tip. Is that in your book somewhere?

I don't think so; not that one... (Noted though; I may get to it.)

I had carefully tried to avoid adding "too much" information. However, as the book progressed added more and more information like that, especially after Luís Marques's recommendations. I am very grateful for the effort he has put into reviewing and editing the book.

Ali

Reply via email to