错误:'operator&lt;'不匹配(操作数类型为'<unresolved overloaded =“”function =“”type =“”>'和'Color')</unresolved>

时间:2014-02-15 10:21:05

标签: c++

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'

请解释一下,我在这里提供了完整的代码。

1 个答案:

答案 0 :(得分:2)

template放在generate功能的generate_moves前面。例如:

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

编译器识别generate是函数类型,但不知道您想将名称视为模板。因此,它将<后面的{{1}}视为小于运算符,导致您看到的错误。