hash_map的问题,急求教,100分
我需要一个hash_map< pair<int,int> , int >的数据结构
#include <utility>
#include <hash_map>
using namespace std;
typedef std::pair<int, int> Edge_Type;
typedef int Map_Type;
typedef std::pair< Edge_Type, Map_Type > Edge;
typedef hash_map< Edge_Type, Map_Type > Edge_Map;
int main()
{
Edge_Map edge_map;
edge_map.insert( std::make_pair( Edge_Type( 2, 2 ), 3 ) );
return 0;
}
但是运行总是抱错,如果是hash_map<int, int>或者hash_map<int, pair<int, int> >就没有问题,不知是什么原因
错误如下,在vc7.1+stlport调试(不用stlport,错误也是一样的)
------ 已启动生成: 项目: faint, 配置: Release Win32 ------
正在编译...
main.cpp
main.cpp(32) : warning C4267: “参数” : 从“size_t”转换到“unsigned int”,可能丢失数据
d:\software\STLPort\stlport\stl\_hashtable.h(566) : error C2064: 项不会计算为接受 1 个参数的函数
d:\software\STLPort\stlport\stl\_hashtable.h(565) : 编译类模板成员函数“_STL::hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>::size_type _STL::hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>::_M_bkt_num_key(const _STL::hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>::key_type &,size_t) const”时
with
[
_Val=_STL::pair<const Edge_Type,Map_Type>,
_Key=Edge_Type,
_HF=_STL::hash<Edge_Type>,
_ExK=_STL::_Select1st<_STL::pair<const Edge_Type,Map_Type>>,
_EqK=_STL::equal_to<Edge_Type>,
_All=_STL::allocator<_STL::pair<const Edge_Type,Map_Type>>
]
d:\software\STLPort\stlport\stl\_hash_map.h(56) : 参见对正在编译的类模板实例化“_STL::hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>”的引用
with
[
_Val=_STL::pair<const Edge_Type,Map_Type>,
_Key=Edge_Type,
_HF=_STL::hash<Edge_Type>,
_ExK=_STL::_Select1st<_STL::pair<const Edge_Type,Map_Type>>,
_EqK=_STL::equal_to<Edge_Type>,
_All=_STL::allocator<_STL::pair<const Edge_Type,Map_Type>>
]
main.cpp(27) : 参见对正在编译的类模板实例化“_STL::hash_map<_Key,_Tp>”的引用
with
[
_Key=Edge_Type,
_Tp=Map_Type
]
生成时间 0:01
faint - 1 错误,1 警告