我想为我的寻路使用地图,但不幸的是我不太熟悉它们。我做的是在这条线出现以下错误的假设在我Pathfinding.h
:std::map<PathNode*, bool> mOpenMap;
错误C2664使用地图
"Error 1 error C2664: 'std::pair<const _Kty,_Ty>::pair(const std::pair<const _Kty,_Ty> &)' : cannot convert argument 1 from 'PathNode *' to 'const std::pair<const _Kty,_Ty> &' c:\program files (x86)\microsoft visual studio 12.0\vc\include\xmemory0 600 1 Pac3D"
我想这是可行的,因为我已经看到了类似的方式使用它人,但无论是我做错了什么或者不应该这样工作,我在考虑后者。
有没有人有任何关于如何解决这个问题的指针?我会很乐意应要求发布更多的代码。
编辑:我用mOpenMap.emplace(start, true);
把我的第一个节点内,从那里出来它通常是currentNode,无一不是PathNode*
我猜你正在使用'mOpenMap.insert(新PathNode);'或类似的东西? – 2014-09-21 14:59:21
我使用'mOpenMap.emplace(start,true);'在我对地图 – 2014-09-21 15:10:27
执行任何操作之前,currentNode是'PathNode *'类型的,对吧? – 2014-09-21 15:10:54