From: Marco Costalba Date: Wed, 21 Jan 2015 16:35:53 +0000 (+0100) Subject: Rearrange Endgames X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=36f8814aa6369a9bce1216556d9382cac34b4678 Rearrange Endgames Remove references to EndgameBase and use instead Value and ScaleFactor as template parameters of the endgames maps. No functional change. --- diff --git a/src/endgame.cpp b/src/endgame.cpp index 82a01b12..836621d2 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -128,9 +128,8 @@ Endgames::Endgames() { template void Endgames::add(const string& code) { - - map()[key(code, WHITE)] = std::unique_ptr(new Endgame(WHITE)); - map()[key(code, BLACK)] = std::unique_ptr(new Endgame(BLACK)); + map()[key(code, WHITE)] = std::unique_ptr>(new Endgame(WHITE)); + map()[key(code, BLACK)] = std::unique_ptr>(new Endgame(BLACK)); } diff --git a/src/endgame.h b/src/endgame.h index 392788cf..cd05f0cd 100644 --- a/src/endgame.h +++ b/src/endgame.h @@ -67,8 +67,8 @@ enum EndgameType { /// Endgame functions can be of two types depending on whether they return a /// Value or a ScaleFactor. -template -using eg_fun = std::conditional<(E < SCALING_FUNCTIONS), Value, ScaleFactor>; +template using +eg_type = typename std::conditional<(E < SCALING_FUNCTIONS), Value, ScaleFactor>::type; /// Base and derived templates for endgame evaluation and scaling functions @@ -82,7 +82,7 @@ struct EndgameBase { }; -template::type> +template> struct Endgame : public EndgameBase { explicit Endgame(Color c) : strongSide(c), weakSide(~c) {} @@ -100,21 +100,25 @@ private: class Endgames { - template using Map = std::map>; + template using Map = std::map>>; - template::type>> + template> void add(const std::string& code); - template>::value> - Map& map() { return std::get(maps); } + template + Map& map() { + return std::get::value>(maps); + } - std::pair>, Map>> maps; + std::pair, Map> maps; public: Endgames(); - template> E* probe(Key key) - { return map().count(key) ? map()[key].get() : nullptr; } + template + EndgameBase* probe(Key key) { + return map().count(key) ? map()[key].get() : nullptr; + } }; #endif // #ifndef ENDGAME_H_INCLUDED