2014-02-15 26 views
1
namespace { 

    template<GenT GT, PieceT PT> 
    // Move Generator for PIECE 
    struct Generator 
    { 

    public: 

     template<Color C> 

     static INLINE void generate (ValMove *&m_list, const Position &pos, Bitboard targets, const CheckInfo *ci = NULL) 
     { 

     } 

    }; 

    template<GenT GT> 
    // Move Generator for KING 
    struct Generator<GT, KING> 
    { 

    public: 

     template<CSide SIDE, bool CHESS960> 

     static INLINE void generate_castling (ValMove *&m_list, const Position &pos, Color C, const CheckInfo *ci /*= NULL*/) 
     { 

     } 

     template<Color C> 
     static INLINE void generate (ValMove *&m_list, const Position &pos, Bitboard targets, const CheckInfo *ci = NULL) 
     { 

     } 

    }; 

    template<GenT GT> 
    // Move Generator for PAWN 
    struct Generator<GT, PAWN> 
    { 

    public: 

     template<Delta D> 
     // Generates PAWN promotion move 
     static INLINE void generate_promotion (ValMove *&m_list, Bitboard pawns_on_R7, Bitboard targets, const CheckInfo *ci) 
     { 

     } 


     template<Color C> 
     static INLINE void generate (ValMove *&m_list, const Position &pos, Bitboard targets, const CheckInfo *ci = NULL) 
     { 

     } 

    }; 



    template<Color C, GenT GT> 
    // Generates all pseudo-legal moves of color for targets. 
    INLINE ValMove* generate_moves (ValMove *&m_list, const Position &pos, Bitboard targets, const CheckInfo *ci = NULL) 
    { 

     // ERROR :: generate<C> 
     // error: no match for 'operator<' (operand types are '<unresolved overloaded function type>' and 'Color' 
     // for ALL CALLS TO generate<C> 

     Generator<GT, PAWN>::generate<C> (m_list, pos, targets, ci); 
     Generator<GT, NIHT>::generate<C> (m_list, pos, targets, ci); 
     Generator<GT, BSHP>::generate<C> (m_list, pos, targets, ci); 
     Generator<GT, ROOK>::generate<C> (m_list, pos, targets, ci); 
     Generator<GT, QUEN>::generate<C> (m_list, pos, targets, ci); 
     if (EVASION != GT) 
     { 
      Generator<GT, KING>::generate<C> (m_list, pos, targets, ci); 
     } 

     return m_list; 
    } 

} 

make.exe -f MakeFile build ARCH=x86-32 COMP=mingw 

爲什麼這個錯誤?我正在用minGW編譯。錯誤:不對應的 '運營商<'(操作數的類型是 '<懸而未決重載的函數類型>' 和 '顏色')

error: no match for 'operator<' (operand types are '<unresolved overloaded function type>' and 'Color'

請解釋一下,我在這裏提供了完整的代碼。

+0

'模板<根特GT,PieceT PT> 結構發電機{} 2專門 模板 結構發生器 {} 模板 結構發生器 {}' –

+0

你能顯示代碼,其中你實際上使用'operator <'? – 0x499602D2

回答

2

在您的generate_moves函數中generate之前加上template。例如:

Generator<GT, PAWN>::template generate<C> (m_list, pos, targets, ci); 

編譯器識別的generate是一個函數類型,但不知道你想處理的名稱作爲模板。因此,它將<作爲小於運算符處理,導致您看到的錯誤。

相關問題