1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-29 08:13:08 +00:00

Use templetized operations for File and Rank

Doing the conversion the compiler is now able to
spot two possible ambiguity calls that now we can
easily fix.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2010-08-18 16:17:20 +01:00
parent 80bee85d5f
commit 4ce08482c3
4 changed files with 9 additions and 18 deletions

View file

@ -214,7 +214,7 @@ Score PawnInfoTable::evaluate_pawns(const Position& pos, Bitboard ourPawns,
pi->qsStormValue[Us] += QStormTable[relative_square(Us, s)] + bonus;
// Our rank plus previous one. Used for chain detection.
b = rank_bb(r) | rank_bb(Us == WHITE ? r - 1 : r + 1);
b = rank_bb(r) | rank_bb(Us == WHITE ? r - Rank(1) : r + Rank(1));
// Passed, isolated, doubled or member of a pawn
// chain (but not the backward one) ?

View file

@ -182,7 +182,7 @@ void Position::from_fen(const string& fen) {
{
if (isdigit(token))
{
file += token - '0'; // Skip the given number of files
file += File(token - '0'); // Skip the given number of files
continue;
}
else if (token == '/')

View file

@ -77,22 +77,6 @@ const int FlopMask = 07;
//// Inline functions
////
inline File operator+ (File x, int i) { return File(int(x) + i); }
inline File operator+ (File x, File y) { return x + int(y); }
inline void operator++ (File &x, int) { x = File(int(x) + 1); }
inline void operator+= (File &x, int i) { x = File(int(x) + i); }
inline File operator- (File x, int i) { return File(int(x) - i); }
inline void operator-- (File &x, int) { x = File(int(x) - 1); }
inline void operator-= (File &x, int i) { x = File(int(x) - i); }
inline Rank operator+ (Rank x, int i) { return Rank(int(x) + i); }
inline Rank operator+ (Rank x, Rank y) { return x + int(y); }
inline void operator++ (Rank &x, int) { x = Rank(int(x) + 1); }
inline void operator+= (Rank &x, int i) { x = Rank(int(x) + i); }
inline Rank operator- (Rank x, int i) { return Rank(int(x) - i); }
inline void operator-- (Rank &x, int) { x = Rank(int(x) - 1); }
inline void operator-= (Rank &x, int i) { x = Rank(int(x) - i); }
inline Square operator+ (Square x, int i) { return Square(int(x) + i); }
inline void operator++ (Square &x, int) { x = Square(int(x) + 1); }
inline void operator+= (Square &x, int i) { x = Square(int(x) + i); }
@ -103,6 +87,7 @@ 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));
}

View file

@ -125,6 +125,12 @@ inline T operator* (int i, const T d) { return T(int(d) * i); }
template<typename T>
inline T operator/ (const T d, int i) { return T(int(d) / i); }
template<typename T>
inline void operator++ (T& d, int) { d = T(int(d) + 1); }
template<typename T>
inline void operator-- (T& d, int) { d = T(int(d) - 1); }
template<typename T>
inline void operator+= (T& d1, const T d2) { d1 = d1 + d2; }