mixing array and string .find()

Brian digitalmars at brianguertin.com
Mon Mar 23 17:11:47 PDT 2009

is it possible to write a generic .find function for arrays that ignores 
strings and so doesn't cause conflicts? I think in D2 its easy by putting 
an if() constraint on the template, but is it possible in D1? like:

int find(T)(T[] array, T obj) {
	foreach (i, v; array) {
		if (v == obj)
			return i;
	return -1;

this conflicts with std.string.find, so i have to import one of them 
statically and use it like.
std.string.find("mystr", "s");

i want to be able to just have:
int[] arr;

string s;

More information about the Digitalmars-d-learn mailing list