Error: cannot uniquely infer foreach argument types

Agustin agustin.l.alvarez at hotmail.com
Fri Jun 14 10:13:06 PDT 2013


Hello, i'm trying to create a library with utilities classes like 
containers using Java API. Could anyone help me?

public interface Iterator(E) {
    bool hasNext();
    E next();
    void remove();
    int opApply(int delegate(ref E) delegation);
}

public class AbstractCollection(E) : Collection!E {

    .....

     E[] toArray(E[] dst = null) {
     	size_t count = size();
     	if( dst.length < count ) {
     		dst.length = count;
     	}
     	Iterator!E it = iterator();
     	foreach(int i,E e; it) { -> Error: cannot uniquely infer 
foreach argument types
     		dst[i] = e;
     	}
     	return dst[0 .. count];
     }

    .....

}


More information about the Digitalmars-d-learn mailing list