Error: cannot uniquely infer foreach argument types

bearophile bearophileHUGS at lycos.com
Fri Jun 14 10:17:45 PDT 2013


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


More information about the Digitalmars-d-learn mailing list