]> git.sesse.net Git - stockfish/commitdiff
Use templetized operations for File and Rank
authorMarco Costalba <mcostalba@gmail.com>
Wed, 18 Aug 2010 15:17:20 +0000 (16:17 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Thu, 19 Aug 2010 12:48:30 +0000 (13:48 +0100)
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>
src/pawns.cpp
src/position.cpp
src/square.h
src/types.h

index b5c377efcd1e30221a514ea050e8787ba8b5a692..5a789ef24bf376063cbbccdddee49d781a2ad035 100644 (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.
       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) ?
 
       // Passed, isolated, doubled or member of a pawn
       // chain (but not the backward one) ?
index c8132d5e513d2a1b2d4aa6a711f96e1440b0b5f7..021113ed7ded96ad2e99c243e356b2ce271cc6ae 100644 (file)
@@ -182,7 +182,7 @@ void Position::from_fen(const string& fen) {
   {
       if (isdigit(token))
       {
   {
       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 == '/')
           continue;
       }
       else if (token == '/')
index e4eab2ac2bad85b6d54717bb41cbc6cf9e86c16e..8de3f55c56016269b0469277053b9626825e1a84 100644 (file)
@@ -77,22 +77,6 @@ const int FlopMask = 07;
 //// Inline functions
 ////
 
 //// 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); }
 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 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 SquareDelta operator- (Square x, Square y) {
   return SquareDelta(int(x) - int(y));
 }
index 4931531b54a87f37e70628c035158c91b9642c8e..f018311dc70f629b4d324a9ed96b379cf0e7f587 100644 (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 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; }
 
 template<typename T>
 inline void operator+= (T& d1, const T d2) { d1 = d1 + d2; }