X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fendgame.h;h=e26418c05a7f1a2d6ea7fedb6667d09f01bf4d0f;hp=195c2365cbe2e6aac15377428e8e28b05109b2a3;hb=c555e1aa962a6a0230be42b87a3486b3c14ada4d;hpb=6963c3802d73c61396af32eb7fc6a4e4a76763ae diff --git a/src/endgame.h b/src/endgame.h index 195c2365..e26418c0 100644 --- a/src/endgame.h +++ b/src/endgame.h @@ -82,7 +82,7 @@ struct EndgameBase { template::type> struct Endgame : public EndgameBase { - explicit Endgame(Color c) : strongerSide(c), weakerSide(opposite_color(c)) {} + explicit Endgame(Color c) : strongerSide(c), weakerSide(flip(c)) {} Color color() const { return strongerSide; } T apply(const Position&) const; @@ -98,20 +98,28 @@ private: struct Endgames { template - struct EMap { typedef std::map*> type; }; + struct Map { typedef std::map*> type; }; + + typedef Map::type M1; + typedef Map::type M2; Endgames(); ~Endgames(); - template EndgameBase* get(Key key) const; + + template + EndgameBase* get(Key key) const { + + typedef typename Map::type M; + typename M::const_iterator it = map().find(key); + return it != map().end() ? it->second : NULL; + } private: template void add(const std::string& keyCode); + template const M& map() const; - // Here we store two maps, for evaluate and scaling functions... - std::pair::type, EMap::type> maps; - - // ...and here is the accessing template function - template const typename EMap::type& map() const; + M1 m1; + M2 m2; }; #endif // !defined(ENDGAME_H_INCLUDED)