On 7/14/21 11:27 AM, Tejas wrote:

> the compiler error should have been a dead giveaway
> that opIndex was returning a _constant_ value

I know you mean "rvalue" but if I may be unnecessarily pedantic, an rvalue can indeed be mutated:

struct A {
  int i;
  void mutate() {
    i = 42;
    import std.stdio;
    writeln("I am not constant. :)");
  }
}

struct B {
  auto opUnary(string op)() {
    return A();
  }
}

void main() {
  auto b = B();
  (++b).mutate();  // <-- Mutating an rvalue
}

Ali

Reply via email to