On 3/30/11 11:21 AM, Cristi Cobzarenco wrote:
Seems right to me, am I missing something?

opAssign isn't taken into consideration when initializing variables or passing values to functions. An example probably says more than thousand words:

---
struct Test {
  ref Test opAssign(int i) {
    value = i;
    return this;
  }
  int value;
}

void foo(Test t) {}

void main() {
    // Neither of the following two lines compiles, IIRC:
    Test t = 4; // (1)
    foo(4); // (2)
}
---

You can make case (1) work by defining a static opCall taking an int, which will be called due to property syntax, but I can't think of any solution for (2).

David

Reply via email to