downs wrote:
Consider this type:

struct StringPosition {
  size_t pos;
  void opImplicitCast(out size_t sz) {
    sz = pos;
  }
  void opImplicitCast(out bool b) {
    b = pos != -1;
  }
}

Wouldn't that effectively sidestep most problems people have with find 
returning -1?

Or am I missing something?

Of course, this would require a way to resolve ambiguities, i.e. functions/statements 
with preferences - for instance, if() would "prefer" bool over int. I don't 
know if this is possible.

Just use two functions: find and contains.

Reply via email to