Error: cannot uniquely infer foreach argument types

Agustin agustin.l.alvarez at hotmail.com
Fri Jun 14 10:25:24 PDT 2013


On Friday, 14 June 2013 at 17:17:46 UTC, bearophile wrote:
> Agustin:
>
>> Hello, i'm trying to create a library with utilities classes 
>> like containers using Java API.
>
> The problem with this is that most Phobos works with ranges...
>
>
>> Could anyone help me?
>
> Maybe your code has multiple problems. If you want a precise 
> answer, then give a complete little program. But a possible 
> problem is in the opApply:
>
> int opApply(int delegate(ref E) delegation);
>
> If you want to use:
>
> foreach (i, e; it) {
>
> Then you need to put both in the opApply (or add a second 
> opApply overload), something like:
>
> int opApply(int delegate(ref int, ref E) delegation);
>
> Bye,
> bearophile

int opApply(int delegate(ref int, ref E) delegation);

Works!, thanks.


More information about the Digitalmars-d-learn mailing list