On Thu, 26 Mar 2015 09:02:53 +0000, Nicolas Sicard wrote:
> 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 !just make sure you didn't add `opUnary` there, as it will kill `opPostInc`. it worth nothing that `opPostInc` is not deprecated yet. ;-)
signature.asc
Description: PGP signature
