c – 错误:没有匹配函数来调用’make_pair(int&,Quest *)’

前端之家收集整理的这篇文章主要介绍了c – 错误:没有匹配函数来调用’make_pair(int&,Quest *)’前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在g中得到了这个奇怪的错误;它在Visual Studio中编译得很好.
  1. struct Quest
  2. {
  3. static map<int,Quest*> Cache;
  4. };
  5.  
  6. Quest *Quest::LoadFromDb(BaseResult& result,int *id)
  7. {
  8. Quest *ret;
  9. if(result.Error())
  10. {
  11. if(id)
  12. Cache.insert(make_pair<int,Quest*>(*id,NULL)); // <--- Problematic line
  13.  
  14. return NULL;
  15. }
  16.  
  17. // ...
  18. }

确切的错误

DataFilesStructure.cpp:9135:58: error: no matching function for
call to ‘make_pair(int&,Quest*)’

解决方法

它是否适用于明确的演员?
  1. if (id)
  2. Cache.insert(make_pair<int,Quest*>(int(*id),NULL));

还有一个9000行的cpp文件,真的吗?

猜你在找的C&C++相关文章