以对作为键并以列表作为值插入到地图中
Insert into map with pair as key and list as value
我在 C++ 中有以下地图:
typedef std::pair<int, int> iPair;
std::map< iPair, std::list< iPair > > world;
我想为一对 (u,v) 插入和更新地图 -> 在列表中推回:
iPair src = make_pair(p1, u1);
iPair dst = make_pair(p2, u2);
map[src].push_back(dst);
我在尝试访问 map[src]
:
时遇到编译错误
error: missing template arguments before ‘[’ token
您需要 world[src]
,因为这是您的地图变量的名称,应该可以。
我在 C++ 中有以下地图:
typedef std::pair<int, int> iPair;
std::map< iPair, std::list< iPair > > world;
我想为一对 (u,v) 插入和更新地图 -> 在列表中推回:
iPair src = make_pair(p1, u1);
iPair dst = make_pair(p2, u2);
map[src].push_back(dst);
我在尝试访问 map[src]
:
error: missing template arguments before ‘[’ token
您需要 world[src]
,因为这是您的地图变量的名称,应该可以。