On Thursday, 26 March 2015 at 04:57:55 UTC, ketmar wrote:
by the way. do you know that you still CAN overload postincrement operation? yes, the code is still here, and it works... somethimes. ;-)
Thnaks. Indeed, this works:
---
struct S
{
int i;
immutable(Object) o;
void opAddAssign(int j) { i += j; }
S opPostInc() { ++i; return this; }
void opAssign(S other) {}
}
unittest
{
S s;
++s;
assert(s.i == 1);
s++;
assert(s.i == 2);
}
---
Old operator overloading to the rescue !
