- // ...and here is the accessing template function
- template<typename T> const std::map<Key, T*>& map() const;
-};
+ template<EndgameCode E, typename T = eg_type<E>>
+ void add(const std::string& code) {
+
+ StateInfo st;
+ map<T>()[Position().set(code, WHITE, &st).material_key()] = Ptr<T>(new Endgame<E>(WHITE));
+ map<T>()[Position().set(code, BLACK, &st).material_key()] = Ptr<T>(new Endgame<E>(BLACK));
+ }
+
+ template<typename T>
+ const EndgameBase<T>* probe(Key key) {
+ auto it = map<T>().find(key);
+ return it != map<T>().end() ? it->second.get() : nullptr;
+ }
+}
+
+} // namespace Stockfish