]> git.sesse.net Git - stockfish/commitdiff
Use templetize enum operations for Depth
authorMarco Costalba <mcostalba@gmail.com>
Wed, 18 Aug 2010 14:58:22 +0000 (15:58 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Thu, 19 Aug 2010 12:48:28 +0000 (13:48 +0100)
Instead of hardcoded ones.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/depth.h
src/evaluate.cpp
src/types.h

index 35430bc55b983e4030d800e4eb9e3bb2f3526d00..ab88f652a4bda753fdeeaac42478027767920276 100644 (file)
@@ -34,18 +34,4 @@ enum Depth {
 };
 
 
-////
-//// Inline functions
-////
-
-inline void operator+= (Depth &d1, Depth d2) { d1 = Depth(int(d1) + int(d2)); }
-inline void operator*= (Depth &d, int i) { d = Depth(int(d) * i); }
-inline void operator/= (Depth &d, int i) { d = Depth(int(d) / i); }
-
-inline Depth operator+ (Depth d1, Depth d2) { return Depth(int(d1) + int(d2)); }
-inline Depth operator- (Depth d1, Depth d2) { return Depth(int(d1) - int(d2)); }
-inline Depth operator* (int i, Depth d) { return Depth(int(d) * i); }
-inline Depth operator/ (Depth d, int i) { return Depth(int(d) / i); }
-
-
 #endif // !defined(DEPTH_H_INCLUDED)
index 74e70fa2530cf6903b553e892ca95188b8484f65..f6a2ed0dcdb0ad3b1d7daf4371f7d6cbe8c12c96 100644 (file)
@@ -1075,9 +1075,9 @@ namespace {
 
     Value eg = eg_value(v);
     ScaleFactor f = sf[eg > Value(0) ? WHITE : BLACK];
-    Value ev = Value((eg * f) / SCALE_FACTOR_NORMAL);
+    Value ev = Value((eg * int(f)) / SCALE_FACTOR_NORMAL);
 
-    int result = (mg_value(v) * ph + ev * (128 - ph)) / 128;
+    int result = (mg_value(v) * int(ph) + ev * int(128 - ph)) / 128;
     return Value(result & ~(GrainSize - 1));
   }
 
index 0c12d930490bb6c4516c817fe2950d67f4c45ec7..4931531b54a87f37e70628c035158c91b9642c8e 100644 (file)
@@ -109,4 +109,29 @@ inline void __cpuid(int CPUInfo[4], int)
 }
 #endif
 
+
+// Templetized enum operations, we avoid to repeat the same inlines for each
+// different enum.
+
+template<typename T>
+inline T operator+ (const T d1, const T d2) { return T(int(d1) + int(d2)); }
+
+template<typename T>
+inline T operator- (const T d1, const T d2) { return T(int(d1) - int(d2)); }
+
+template<typename T>
+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& d1, const T d2) { d1 = d1 + d2; }
+
+template<typename T>
+inline void operator*= (T& d, int i) { d = T(int(d) * i); }
+
+template<typename T>
+inline void operator/= (T &d, int i) { d = T(int(d) / i); }
+
 #endif // !defined(TYPES_H_INCLUDED)