X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fendgame.h;h=424a3591cb80e6a67b22c784f524621186d28a98;hp=61b8c0960e94ac4827d6de6c330aeff708ed0088;hb=dda0fa1a43e1096415ff8f83dd14e6322f1a8e68;hpb=7eb6a488ade31254151fd516aa4c94fc56b84a1f diff --git a/src/endgame.h b/src/endgame.h index 61b8c096..424a3591 100644 --- a/src/endgame.h +++ b/src/endgame.h @@ -61,11 +61,12 @@ enum EndgameType { }; -/// Some magic to detect family type of endgame from its enum value +/// Endgame functions can be of two types according if return a Value or a +/// ScaleFactor. Type eg_fun::type equals to either ScaleFactor or Value +/// depending if the template parameter is 0 or 1. -template struct bool_to_type { typedef Value type; }; -template<> struct bool_to_type { typedef ScaleFactor type; }; -template struct eg_family : public bool_to_type<(E > SCALE_FUNS)> {}; +template struct eg_fun { typedef Value type; }; +template<> struct eg_fun<1> { typedef ScaleFactor type; }; /// Base and derived templates for endgame evaluation and scaling functions @@ -79,7 +80,7 @@ struct EndgameBase { }; -template::type> +template SCALE_FUNS)>::type> struct Endgame : public EndgameBase { explicit Endgame(Color c) : strongerSide(c), weakerSide(~c) {} @@ -97,14 +98,14 @@ private: class Endgames { - typedef std::map*> M1; - typedef std::map*> M2; + typedef std::map::type>*> M1; + typedef std::map::type>*> M2; M1 m1; M2 m2; - M1& map(Value*) { return m1; } - M2& map(ScaleFactor*) { return m2; } + M1& map(M1::value_type::second_type) { return m1; } + M2& map(M2::value_type::second_type) { return m2; } template void add(const std::string& code); @@ -113,7 +114,7 @@ public: ~Endgames(); template EndgameBase* probe(Key key) { - return map((T*)0).count(key) ? map((T*)0)[key] : NULL; + return map((EndgameBase*)0).count(key) ? map((EndgameBase*)0)[key] : NULL; } };