mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
Use templetized operations for Square
This is tricky because there are some special binary fnctions with SquareDelta that we should leave as they are. Also note that we needed to add Unary minus template to fix a comile error in SERIALIZE_MOVES_D macro that was triggered because now we don't allow conversion to int. No fuctional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
4ce08482c3
commit
8e31764c49
2 changed files with 7 additions and 14 deletions
18
src/square.h
18
src/square.h
|
@ -77,20 +77,10 @@ const int FlopMask = 07;
|
||||||
//// Inline functions
|
//// Inline functions
|
||||||
////
|
////
|
||||||
|
|
||||||
inline Square operator+ (Square x, int i) { return Square(int(x) + i); }
|
inline Square operator+ (Square x, SquareDelta i) { return x + Square(i); }
|
||||||
inline void operator++ (Square &x, int) { x = Square(int(x) + 1); }
|
inline void operator+= (Square& x, SquareDelta i) { x = x + Square(i); }
|
||||||
inline void operator+= (Square &x, int i) { x = Square(int(x) + i); }
|
inline Square operator- (Square x, SquareDelta i) { return x - Square(i); }
|
||||||
inline Square operator- (Square x, int i) { return Square(int(x) - i); }
|
inline void operator-= (Square& x, SquareDelta i) { x = x - Square(i); }
|
||||||
inline void operator-- (Square &x, int) { x = Square(int(x) - 1); }
|
|
||||||
inline void operator-= (Square &x, int i) { x = Square(int(x) - i); }
|
|
||||||
inline Square operator+ (Square x, SquareDelta i) { return Square(int(x) + i); }
|
|
||||||
inline void operator+= (Square &x, SquareDelta i) { x = Square(int(x) + i); }
|
|
||||||
inline Square operator- (Square x, SquareDelta i) { return Square(int(x) - i); }
|
|
||||||
inline void operator-= (Square &x, SquareDelta i) { x = Square(int(x) - i); }
|
|
||||||
|
|
||||||
inline SquareDelta operator- (Square x, Square y) {
|
|
||||||
return SquareDelta(int(x) - int(y));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Square make_square(File f, Rank r) {
|
inline Square make_square(File f, Rank r) {
|
||||||
return Square(int(f) | (int(r) << 3));
|
return Square(int(f) | (int(r) << 3));
|
||||||
|
|
|
@ -125,6 +125,9 @@ inline T operator* (int i, const T d) { return T(int(d) * i); }
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline T operator/ (const T d, int i) { return T(int(d) / i); }
|
inline T operator/ (const T d, int i) { return T(int(d) / i); }
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline T operator- (const T d) { return T(-int(d)); }
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline void operator++ (T& d, int) { d = T(int(d) + 1); }
|
inline void operator++ (T& d, int) { d = T(int(d) + 1); }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue