]> git.sesse.net Git - stockfish/commit
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)
commit7a1ff6d8ff39bb9e6844d24467899d47e942486f
tree36b9c4d5a7fe6a890ae61f45c46da18015bac1b7
parent82f6779c2e549a264dbfc76d4c668f4c2ea831cd
Fix operator++ definition

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.
src/bitboard.cpp
src/evaluate.cpp
src/position.cpp
src/types.h