From: Marco Costalba Date: Fri, 17 Jul 2009 17:16:20 +0000 (+0200) Subject: Fix two compile errors in new endgame code X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=20e87389019187dd7586d3ffb12b632d5ec5d048 Fix two compile errors in new endgame code Code that compiles cleanly under MSVC triggers one compile error (correct) under Intel C++ and two(!) under gcc. The first is the same complained by Intel, but the second is an interesting corner case of C++ standard (there are many) that is correctly spotted only by gcc. Both MSVC and Intel pass this silently, probably to avoid breaking people code. Now we are fully C++ compliant ;-) Signed-off-by: Marco Costalba --- diff --git a/src/material.cpp b/src/material.cpp index 57cf05ca..3fc05db8 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -57,15 +57,13 @@ namespace { //// Classes //// +typedef EndgameEvaluationFunctionBase EF; +typedef EndgameScalingFunctionBase SF; /// See header for a class description. It is declared here to avoid /// to include in the header file. class EndgameFunctions { - - typedef EndgameEvaluationFunctionBase EF; - typedef EndgameScalingFunctionBase SF; - public: EndgameFunctions(); ~EndgameFunctions(); @@ -82,11 +80,17 @@ private: // Maps accessing functions for const and non-const references template const std::map& map() const { return EEFmap; } - template<> const std::map& map() const { return ESFmap; } template std::map& map() { return EEFmap; } - template<> std::map& map() { return ESFmap; } }; +// Explicit specializations of a member function shall be declared in +// the namespace of which the class template is a member. +template<> const std::map& +EndgameFunctions::map() const { return ESFmap; } + +template<> std::map& +EndgameFunctions::map() { return ESFmap; } + //// //// Functions @@ -151,7 +155,7 @@ MaterialInfo* MaterialInfoTable::get_material_info(const Position& pos) { // Let's look if we have a specialized evaluation function for this // particular material configuration. First we look for a fixed // configuration one, then a generic one if previous search failed. - if ((mi->evaluationFunction = funcs->get(key)) != NULL) + if ((mi->evaluationFunction = funcs->get(key)) != NULL) return mi; else if ( pos.non_pawn_material(BLACK) == Value(0) @@ -192,9 +196,9 @@ MaterialInfo* MaterialInfoTable::get_material_info(const Position& pos) { // if we decide to add more special cases. We face problems when there // are several conflicting applicable scaling functions and we need to // decide which one to use. - EndgameScalingFunctionBase* sf; + SF* sf; - if ((sf = funcs->get(key)) != NULL) + if ((sf = funcs->get(key)) != NULL) { mi->scalingFunction[sf->color()] = sf; return mi; @@ -393,6 +397,6 @@ void EndgameFunctions::add(const string& keyCode) { template T* EndgameFunctions::get(Key key) const { - std::map::const_iterator it(map().find(key)); + typename std::map::const_iterator it(map().find(key)); return (it != map().end() ? it->second : NULL); }