C++ C++;传递比较函子时发生std::map编译器错误

C++ C++;传递比较函子时发生std::map编译器错误,c++,compare,functor,stdmap,C++,Compare,Functor,Stdmap,我在我相信的某个地方做出了一个错误的假设。我假设std::map只在索引中进行比较。然而,它不是试图比较两个uint64s,而是试图将其中一个与其他东西进行比较(请参见编译器错误) struct标记{}; typedef句柄HPowerType; 类PowerTypeMgr { 结构PowerType{/**stuff**/}; 结构uint64_以下 { 布尔运算符()(常数uint64&l、常数uint64&r)常数 { 返回((l原因:无法从'PowerTypeMgr::PowerType

我在我相信的某个地方做出了一个错误的假设。我假设
std::map
只在索引中进行比较。然而,它不是试图比较两个
uint64
s,而是试图将其中一个与其他东西进行比较(请参见编译器错误)

struct标记{};
typedef句柄HPowerType;
类PowerTypeMgr
{
结构PowerType{/**stuff**/};
结构uint64_以下
{
布尔运算符()(常数uint64&l、常数uint64&r)常数
{
返回((l原因:无法从'PowerTypeMgr::PowerType*const'转换为'const'
uint64'
2> 没有可以进行此转换的上下文
2> c:\cry\u v340\u 3696\code\sdks\stlport\stlport\stl\\u tree.h(570):参见
对函数模板实例化“bool”的引用
stlpd_std::priv::_DbgCompare::operator()(const _Kp1&,const
_正在编译Kp2&)const
2> 与
2>          [
2> \u Key=unsigned\u int64,
2> \u Compare=PowerTypeMgr::uint64\u less,
2> _KT=PowerTypeMgr::PowerType*,
2> _Kp1=无符号uu int64,
2> \u Kp2=PowerTypeMgr::PowerType*
2>          ]
这里是完整的用法,因为我似乎没有发布足够的内容。注意,如果我没有通过std::map functor,我会得到相同的错误。我将在这里发布其他方法。

class PowerTypeMgr
{
public:

    virtual ~PowerTypeMgr();

    PowerTypeMgr& Instance()
    {
        static PowerTypeMgr Obj;
        return Obj;
    }

    HPowerType StorePowerType ( 
        uint64 EMP, uint64 ESP, int wC, int chiC, int hC, const char* MPName, 
        const char* SPName, bool isC, bool unlock,const char* PN,const char* PC,
        const char* FMT
    );

    void DeletePowerType(HPowerType Hpt);   //not needed for powertypes, 
                                            //they should always be loaded or unloaded together

    uint64 makePowerString(EMainPowers EMP, ESubPowers ESP);

    bool    IsComboable(HPowerType Hpt) const;
    string  GetPowerName(HPowerType Hpt) const;
    string  GetMPEffectName(HPowerType Hpt) const;
    string  GetSPEffectName(HPowerType Hpt) const;
    string  GetProjectileClass(HPowerType Hpt) const;
    string  GetFireModeType(HPowerType Hpt) const;
    int     GetHealthCost(HPowerType Hpt) const;
    int     GetCHICost(HPowerType Hpt) const;
    int     GetWeaponCost(HPowerType Hpt) const;
    bool    IsUnlocked(HPowerType Hpt) const;
    uint64  GetPowerString(HPowerType Hpt) const;

    // Only things that may change during the course of game execution //
    void    StorePowerName(HPowerType Hpt, string pn);
    void    Unlock(HPowerType Hpt);//, bool L);             //true = unlock it
    void    Lock(HPowerType Hpt);

    bool SaveGame(/* GamePak, SaveName*/) {}//TODO
    bool LoadGame(/* GamePak, SaveName*/) {}//TODO


        private:

    struct PowerType 
    {
        uint64 thePower; //64-bit string where uppermost 8 bits is the EMainPower, and lower 56 is ESubPower
        EMainPowers mainPower; //currently unused
        ESubPowers subPower; //ditto

        bool isComboable;
        bool isUnlocked;
        int weaponCost; //weapon cost (to hold)
        int CHIcost; //cost to CHI meter to use it.
        int healthCost; //additional healthCost to use it
        string powerName;
        string MPEffectName;
        string SPEffectName;
        string projectileClass;
        string fireModeType;

        //MEMBERS --------------------------------------------------<<<
        void Unload();

        EMainPowers getMainPower() const;
        EMainPowers convertToMainPower(const uint64& bitstring);
        ESubPowers getSubPower() const;
        ESubPowers convertToSubPower(const uint64& bitstring);

    }; //end struct PowerType
    //--------------------------------------------------------------------------------------------------------


    PowerTypeMgr(); //SINGLETON pattern


    typedef std::pair<uint64,HPowerType>        PowerMap_Pair;  
    typedef std::map <uint64,HPowerType>        PTHMap;//,int64_less>       PTHMap; //,uint64_less>     PTHMap;         //O(logn) look up bitstr
    PTHMap                                      m_PTHMap;       //...

    typedef std::pair<PTHMap::iterator,bool>    indexInsertRC;

    typedef HandleMgr <PowerType, HPowerType>   PowerHandle;
    PowerHandle                                 m_PowerTypeHMgr;

    bool                                        inited;             //Used in assert & checking if trying to load more than once
    int                                         totalPowerTypes;
        }; //end PowerTypeMgr
class-PowerTypeMgr
{
公众:
虚拟~PowerTypeMgr();
PowerTypeMgr&实例()
{
静态PowerTypeMgr Obj;
返回Obj;
}
HPowerType存储电源类型(
uint64 EMP、uint64 ESP、int wC、int chiC、int hC、const char*MPName、,
常量字符*SPName,布尔isC,布尔解锁,常量字符*PN,常量字符*PC,
常量字符*FMT
);
void DeletePowerType(HPowerType Hpt);//PowerType不需要,
//它们应始终一起装载或卸载
uint64 makePowerString(EMainPowers EMP、ESubPowers ESP);
布尔可编译(HPowerType Hpt)常数;
字符串GetPowerName(HPowerType Hpt)const;
字符串GetMPEffectName(HPowerType Hpt)常量;
字符串GetSPEffectName(HPowerType Hpt)常量;
字符串GetProjectEleClass(HPowerType Hpt)常量;
字符串GetFireModeType(HPowerType Hpt)常量;
int GetHealthCost(HPowerType Hpt)常量;
int GetCHICost(HPowerType Hpt)常量;
int GetWeaponCost(HPowerType Hpt)常数;
布尔未锁定(HPowerType Hpt)常量;
uint64 GetPowerString(HPowerType Hpt)常量;
//只有在游戏执行过程中可能发生变化的事情//
void StorePowerName(HPowerType Hpt,字符串pn);
无效解锁(HPowerType Hpt);//,bool);//true=解锁它
无效锁(HPowerType Hpt);
bool SaveGame(/*GamePak,SaveName*/){}//TODO
bool LoadGame(/*GamePak,SaveName*/){}//TODO
私人:
结构PowerType
{
uint64功率;//64位字符串,其中最高8位为EMainPower,最低56位为ESubPower
EMainPowers mainPower;//当前未使用
ESubPowers次电源;//同上
布尔是可信任的;
布尔解锁;
int武器成本;//武器成本(持有)
int CHIcost;//使用它的成本。
int healthCost;//使用它的额外healthCost
字符串powerName;
字符串名称;
字符串SPEffectName;
弦射影类;
字符串模式类型;
//成员-------------------------------------------PTHMap;//O(logn)查找bitstr
PTHMap m_PTHMap;/。。。
typedef std::pair indexInsertRC;
typedef HandleMgr PowerHandle;
PowerHandle m_PowerTypeHMgr;
bool inited;//在尝试多次加载时用于断言和检查
整数型;
};//结束PowerTypeMgr
这是编译器错误(VC Express 2010)

'2>PowerTypeMgr.cpp
2> c:\cry_v340_3696\code\sdks\stlport\stlport\stl\debug\\ tree.h(62):错误C2664:'bool stlpd_std::less::operator()(const(const)Tp&,const(Tp&),const):无法将参数2从'PowerTypeMgr::PowerType*const'转换为'const uint64&'
2> 与
2>          [
2> _Tp=uint64
2>          ]
2> 原因:无法从“PowerTypeMgr::PowerType*const”转换为“const uint64”
2> 没有可以进行此转换的上下文
2> c:\cry\u v340\u 3696\code\sdks\stlport\stlport\stl\\u tree.h(570):请参阅正在编译的函数模板实例化“bool stlpd\u std::priv::_DbgCompare::operator()(const(u Kp1&,const)Kp2&)const”
2> 与
2>          [
2> \u Key=unsigned\u int64,
2> _Compare=stlpd_std::less,
2> _KT=PowerTypeMgr::PowerType*,
2> _Kp1=无符号uu int64,
2> \u Kp2=PowerTypeMgr::PowerType*
2>          ]
2> c:\cry\u v340\u 3696\code\sdks\stlport\stlport\stl\\ tree.h(560):请参阅正在编译的函数模板实例化“stlpd_std::priv::_NonDbg_Rb_tree::_Base_ptr stlpd_stl::priv:_NonDbg_Rb_tree::_M_find(const)KT&)const”
2> 与
2>          [
2> \u Key=unsigned\u int64,
2> _Compare=stlpd_std::priv::_DbgCompare,
2> _值=stlpd_std::pair,
2> _KeyOfValue=stlpd_std::priv::_选择第一,
2> _Traits=stlpd_std::priv:_MapTraitsT,
2> _Alloc=stlpd_std::分配器,
2> _KT=PowerTypeMgr::PowerType*
2>          ]
2> c:\cry\u v340\u 3696\code\sdks\stlport\stlport\stl\debug\_
    c:\cry_v340_3696\code\sdks\stlport\stlport\stl\debug\_tree.h(62): error C2664:
    'bool PowerTypeMgr::uint64_less::operator ()(const uint64 &,const uint64 &) const' : 
    cannot convert parameter 2 from 'PowerTypeMgr::PowerType *const ' to 'const uint64&'

   2>          Reason: cannot convert from 'PowerTypeMgr::PowerType *const ' to 'const 
   uint64'
   2>          There is no context in which this conversion is possible
   2>          c:\cry_v340_3696\code\sdks\stlport\stlport\stl\_tree.h(570) : see         
   reference to function template instantiation 'bool    
   stlpd_std::priv::_DbgCompare<_Key,_Compare>::operator ()<_Key,_KT>(const _Kp1 &,const 
   _Kp2 &) const' being compiled

   2>          with
   2>          [
   2>              _Key=unsigned __int64,
   2>              _Compare=PowerTypeMgr::uint64_less,
   2>              _KT=PowerTypeMgr::PowerType *,
   2>              _Kp1=unsigned __int64,
   2>              _Kp2=PowerTypeMgr::PowerType *
   2>          ]
class PowerTypeMgr
{
public:

    virtual ~PowerTypeMgr();

    PowerTypeMgr& Instance()
    {
        static PowerTypeMgr Obj;
        return Obj;
    }

    HPowerType StorePowerType ( 
        uint64 EMP, uint64 ESP, int wC, int chiC, int hC, const char* MPName, 
        const char* SPName, bool isC, bool unlock,const char* PN,const char* PC,
        const char* FMT
    );

    void DeletePowerType(HPowerType Hpt);   //not needed for powertypes, 
                                            //they should always be loaded or unloaded together

    uint64 makePowerString(EMainPowers EMP, ESubPowers ESP);

    bool    IsComboable(HPowerType Hpt) const;
    string  GetPowerName(HPowerType Hpt) const;
    string  GetMPEffectName(HPowerType Hpt) const;
    string  GetSPEffectName(HPowerType Hpt) const;
    string  GetProjectileClass(HPowerType Hpt) const;
    string  GetFireModeType(HPowerType Hpt) const;
    int     GetHealthCost(HPowerType Hpt) const;
    int     GetCHICost(HPowerType Hpt) const;
    int     GetWeaponCost(HPowerType Hpt) const;
    bool    IsUnlocked(HPowerType Hpt) const;
    uint64  GetPowerString(HPowerType Hpt) const;

    // Only things that may change during the course of game execution //
    void    StorePowerName(HPowerType Hpt, string pn);
    void    Unlock(HPowerType Hpt);//, bool L);             //true = unlock it
    void    Lock(HPowerType Hpt);

    bool SaveGame(/* GamePak, SaveName*/) {}//TODO
    bool LoadGame(/* GamePak, SaveName*/) {}//TODO


        private:

    struct PowerType 
    {
        uint64 thePower; //64-bit string where uppermost 8 bits is the EMainPower, and lower 56 is ESubPower
        EMainPowers mainPower; //currently unused
        ESubPowers subPower; //ditto

        bool isComboable;
        bool isUnlocked;
        int weaponCost; //weapon cost (to hold)
        int CHIcost; //cost to CHI meter to use it.
        int healthCost; //additional healthCost to use it
        string powerName;
        string MPEffectName;
        string SPEffectName;
        string projectileClass;
        string fireModeType;

        //MEMBERS --------------------------------------------------<<<
        void Unload();

        EMainPowers getMainPower() const;
        EMainPowers convertToMainPower(const uint64& bitstring);
        ESubPowers getSubPower() const;
        ESubPowers convertToSubPower(const uint64& bitstring);

    }; //end struct PowerType
    //--------------------------------------------------------------------------------------------------------


    PowerTypeMgr(); //SINGLETON pattern


    typedef std::pair<uint64,HPowerType>        PowerMap_Pair;  
    typedef std::map <uint64,HPowerType>        PTHMap;//,int64_less>       PTHMap; //,uint64_less>     PTHMap;         //O(logn) look up bitstr
    PTHMap                                      m_PTHMap;       //...

    typedef std::pair<PTHMap::iterator,bool>    indexInsertRC;

    typedef HandleMgr <PowerType, HPowerType>   PowerHandle;
    PowerHandle                                 m_PowerTypeHMgr;

    bool                                        inited;             //Used in assert & checking if trying to load more than once
    int                                         totalPowerTypes;
        }; //end PowerTypeMgr
   '2>  PowerTypeMgr.cpp
    2>c:\cry_v340_3696\code\sdks\stlport\stlport\stl\debug\_tree.h(62): error C2664: 'bool stlpd_std::less<_Tp>::operator ()(const _Tp &,const _Tp &) const' : cannot convert parameter 2 from 'PowerTypeMgr::PowerType *const ' to 'const uint64 &'
    2>          with
    2>          [
    2>              _Tp=uint64
    2>          ]
    2>          Reason: cannot convert from 'PowerTypeMgr::PowerType *const ' to 'const uint64'
    2>          There is no context in which this conversion is possible
    2>          c:\cry_v340_3696\code\sdks\stlport\stlport\stl\_tree.h(570) : see reference to function template instantiation 'bool stlpd_std::priv::_DbgCompare<_Key,_Compare>::operator ()<_Key,_KT>(const _Kp1 &,const _Kp2 &) const' being compiled
    2>          with
    2>          [
    2>              _Key=unsigned __int64,
    2>              _Compare=stlpd_std::less<uint64>,
    2>              _KT=PowerTypeMgr::PowerType *,
    2>              _Kp1=unsigned __int64,
    2>              _Kp2=PowerTypeMgr::PowerType *
    2>          ]
    2>          c:\cry_v340_3696\code\sdks\stlport\stlport\stl\_tree.h(560) : see reference to function template instantiation 'stlpd_std::priv::_NonDbg_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc>::_Base_ptr stlpd_std::priv::_NonDbg_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc>::_M_find<_KT>(const _KT &) const' being compiled
    2>          with
    2>          [
    2>              _Key=unsigned __int64,
    2>              _Compare=stlpd_std::priv::_DbgCompare<unsigned __int64,stlpd_std::less<uint64>>,
    2>              _Value=stlpd_std::pair<const uint64,HPowerType>,
    2>              _KeyOfValue=stlpd_std::priv::_Select1st<stlpd_std::pair<const uint64,HPowerType>>,
    2>              _Traits=stlpd_std::priv::_MapTraitsT<stlpd_std::pair<const uint64,HPowerType>>,
    2>              _Alloc=stlpd_std::allocator<stlpd_std::pair<const uint64,HPowerType>>,
    2>              _KT=PowerTypeMgr::PowerType *
    2>          ]
    2>          c:\cry_v340_3696\code\sdks\stlport\stlport\stl\debug\_tree.h(178) : see  
    reference to function template instantiation 'stlpd_std::priv::_Rb_tree_iterator<_Value,_Traits> stlpd_std::priv::_NonDbg_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc>::find<_KT>(const _KT &)' being compiled
    2>          with
    2>          [
    2>              _Value=stlpd_std::pair<const uint64,HPowerType>,
    2>              _Traits=stlpd_std::priv::_MapTraitsT<stlpd_std::pair<const uint64,HPowerType>>,
    2>              _Key=unsigned __int64,
    2>              _Compare=stlpd_std::priv::_DbgCompare<unsigned __int64,stlpd_std::less<uint64>>,
   2>              _KeyOfValue=stlpd_std::priv::_Select1st<stlpd_std::pair<const uint64,HPowerType>>,
    2>              _Alloc=stlpd_std::allocator<stlpd_std::pair<const uint64,HPowerType>>,
   2>              _KT=PowerTypeMgr::PowerType *
   2>          ]
   2>          c:\cry_v340_3696\code\sdks\stlport\stlport\stl\_map.h(214) : see reference to function template instantiation 'stlpd_std::priv::_DBG_iter<_Container,_Traits> stlpd_std::priv::_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,stlpd_std::priv::_MapTraitsT<_Tp>,_Alloc>::find<_KT>(const _KT &)' being compiled
   2>          with
   2>          [
   2>              _Container=stlpd_std::priv::_NonDbg_Rb_tree<unsigned __int64,stlpd_std::priv::_DbgCompare<unsigned __int64,stlpd_std::less<uint64>>,stlpd_std::pair<const uint64,HPowerType>,stlpd_std::priv::_Select1st<stlpd_std::pair<const uint64,HPowerType>>,stlpd_std::priv::_MapTraitsT<stlpd_std::pair<const uint64,HPowerType>>,stlpd_std::allocator<stlpd_std::pair<const uint64,HPowerType>>>,
   2>              _Traits=stlpd_std::priv::_DbgTraits<stlpd_std::priv::_MapTraitsT<stlpd_std::pair<const uint64,HPowerType>>>,
    2>              _Key=unsigned __int64,
    2>              _Compare=stlpd_std::less<uint64>, 
    2>              _Value=stlpd_std::pair<const uint64,HPowerType>,
    2>              _KeyOfValue=stlpd_std::priv::_Select1st<stlpd_std::pair<const uint64,HPowerType>>,
    2>              _Tp=stlpd_std::pair<const uint64,HPowerType>,
    2>              _Alloc=stlpd_std::allocator<stlpd_std::pair<const uint64,HPowerType>>,
    2>              _KT=PowerTypeMgr::PowerType *
    2>          ]
    2>          c:\cry_v340_3696\code\game\gamedll\monk\powertypemgr.cpp(78) : see reference to function template instantiation 'stlpd_std::priv::_DBG_iter<_Container,_Traits> stlpd_std::map<_Key,_Tp>::find<PowerTypeMgr::PowerType*>(const _KT &)' being compiled
    2>          with
     2>          [
    2>              _Container=stlpd_std::priv::_NonDbg_Rb_tree<unsigned __int64,stlpd_std::priv::_DbgCompare<unsigned __int64,stlpd_std::less<uint64>>,stlpd_std::pair<const uint64,HPowerType>,stlpd_std::priv::_Select1st<stlpd_std::pair<const uint64,HPowerType>>,stlpd_std::priv::_MapTraitsT<stlpd_std::pair<const uint64,HPowerType>>,stlpd_std::allocator<stlpd_std::pair<const uint64,HPowerType>>>,
    2>              _Traits=stlpd_std::priv::_DbgTraits<stlpd_std::priv::_MapTraitsT<stlpd_std::pair<const uint64,HPowerType>>>,
    2>              _Key=uint64,
    2>              _Tp=HPowerType,
    2>              _KT=PowerTypeMgr::PowerType *
    2>          ]
    2>c:\cry_v340_3696\code\sdks\stlport\stlport\stl\debug\_tree.h(62): error C2664: 'bool stlpd_std::less<_Tp>::operator ()(const _Tp &,const _Tp &) const' : cannot convert parameter 1 from 'PowerTypeMgr::PowerType *const ' to 'const uint64 &'
    2>          with
    2>          [
 2>              _Tp=uint64
 2>          ]
 2>          Reason: cannot convert from 'PowerTypeMgr::PowerType *const ' to 'const uint64'
 2>          There is no context in which this conversion is possible
 2>          c:\cry_v340_3696\code\sdks\stlport\stlport\stl\_tree.h(576) : see reference to function template instantiation 'bool stlpd_std::priv::_DbgCompare<_Key,_Compare>::operator ()<_KT,_Key>(const _Kp1 &,const _Kp2 &) const' being compiled
2>          with
 2>          [
 2>              _Key=unsigned __int64,
 2>              _Compare=stlpd_std::less<uint64>,
 2>              _KT=PowerTypeMgr::PowerType *,
 2>              _Kp1=PowerTypeMgr::PowerType *,
 2>              _Kp2=unsigned __int64
 2>          ]
 2>  PowerWeapon.cpp
  ...'