mixing array and string .find()
BCS
none at anon.com
Mon Mar 23 23:13:54 PDT 2009
Hello Brian,
> 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:
>
one solution is to dump the std.string.find (or alias it) and have the templated
function cover that case as well.
template find(T) // untested so that might not work
{
int find(T[] array, T obj) { ... }
static if(is(T == char)
alias std.string.find find;
else
int find(T[] array, T[] obj) { ... }
}
More information about the Digitalmars-d-learn
mailing list