opIn_r not detected
spir
denis.spir at gmail.com
Thu Feb 10 04:59:06 PST 2011
Hello,
Implicite deref of struct pointers on member access works fine for data,
methods, even special methods with language semantics like opEquals (see
example below).
But I cannot have 'in' work with method opIn_r. I get:
Error: rvalue of in expression must be an associative array, not S*
What do I have wrong? Or is it a bug: the compiler does not even search the
struct for opIn_r? But then, why does it do it for opEquals?
Denis
struct S {
int i;
void show() { writeln(i); }
const bool opEquals (ref const(S) s) {
writeln("==");
return (i == s.i);
}
bool opIn_r (int j) { return (i==j); }
}
unittest {
S* sp = &(S(1));
writeln(sp.i);
sp.show();
S s2 = S(1);
writeln(sp == s2);
writeln(1 in sp);
}
--
_________________
vita es estrany
spir.wikidot.com
More information about the Digitalmars-d-learn
mailing list