]> git.sesse.net Git - stockfish/commitdiff
Fix operator++ definition
authorMarco Costalba <mcostalba@gmail.com>
Sun, 15 Sep 2013 07:02:09 +0000 (09:02 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 15 Sep 2013 07:09:06 +0000 (09:09 +0200)
ENABLE_OPERATORS_ON has incorrect definitions of
post-increment and post-decrement operators.

In particularly the returned value is the variable
already incremented/decremented, while instead they
should return the variable _before_ inc/dec.

This has no real effect because are only used in loops
and where the returned value is never used, neverthless
it is wrong. The fix would be to copy the variable to a
dummy, then inc/dec the variable, then return the dummy.

So instead, rename to pre-increment that can be implemented
without the dummy, actually the current implementation
it is already the correct pre-increment, with the only change
to return a reference (an l-value) and not a copy, so
to properly mimic the pre-increment on native integers.

Spotted by Kojirion.

No functional change.


No differences found