日期:2014-05-16  浏览次数:20622 次

hash_map编译不过
# if Cactus_COMP_VER >= 430
# define __HashMap ::std::tr1::unordered_map
# define __HashSet ::std::tr1::unordered_set
# define __HashCmp(x) ::std::tr1::hash< x >
# else
# define __HashMap ::__gnu_cxx::hash_map
# define __HashSet ::__gnu_cxx::hash_set
# define __HashCmp(x) ::__gnu_cxx::hash< x >
# endif


template <typename K, typename V, typename P = __HashCmp(K), typename A = STLAllocator<std::pair<const K, V>, GeneralAllocPolicy> >
struct hashmap
{
#if Ogre_Container_Use_MemAlloc
typedef typename __HashMap<K, V, P, A> type;
#else
typedef typename __HashMap<K, V, P> type;
#endif
};

class DBCFileManager
{
     typedef Cactus::hashmap<Cactus::String, Cactus::DBCFile*>::type KeyDBCFileMapType;
KeyDBCFileMapType _DBCFiles;
}

bool DBCFileManager::AddDBCFile(const Cactus::String& strKey, Cactus::DBCFile* pFile)
{
Safe;

if (_DBCFiles.find(strKey) != _DBCFiles.end()) //报错
return false;

Log_Debug("DBCManager::AddDBCFile, " << strKey);
_DBCFiles[strKey] = pFile;

return true;

UnSafe;

return false;
}

报错信息:../DBCFileManager.cpp:131:   instantiated from here
/usr/include/c++/4.4/tr1_impl/hashtable_policy.h:769: error: no match for call to ‘(const Cactus::STLAllocator<std::pair<const std::basic_string<char, std::char_traits<char>, Cactus::STLAllocator<char, Cactus::GeneralAllocPolicy> >, Cactus::DBCFile*>, Cactus::GeneralAllocPolicy>) (const std::basic_string<char, std::char_traits<char>, Cactus::STLAllocator<char, Cactus::GeneralAllocPolicy> >&, const std::basic_string<char, std::char_traits<char>, Cactus::STLAllocator<char, Cactus::GeneralAllocPolicy> >&)’
make: *** [DBCFileManager.o] 错误 1

------解决方案--------------------