A opIndexUnary quiz

Era Scarecrow rtcvb32 at yahoo.com
Tue Jan 1 11:32:09 PST 2013


On Tuesday, 1 January 2013 at 17:52:20 UTC, bearophile wrote:
> A small quiz (it's a reprise of an older discussion). This code 
> compiles with no errors, but do you see anything wrong here?

  Well I see that you have opIndexUnary twice; According to the 
manual you wouldn't need as it would rewrite the code so you only 
need it once; Also they return void when they should return the 
value of x before/after the change.

  Also although the alias this makes the number increment, it 
should be specifying 'x', not that it seems to make a difference.

> Do you think this code should produce some compilation errors?

  As it is I don't see any problems...


More information about the Digitalmars-d-learn mailing list