C++ 从嵌套多重映射访问多重映射::equal_range返回的所有值

C++ 从嵌套多重映射访问多重映射::equal_range返回的所有值,c++,map,multimap,C++,Map,Multimap,我声明了一个包含字符串和映射的多重映射。该映射包含字符串和一对整数 std::multimap<string, std::map<string, std::pair<int, int>>> traders; std::map<string, std::pair<int, int>> products; std::pair<int, int> side; std::多地图交易者; 地图产品; std::对侧; 我通过以下方

我声明了一个包含字符串和映射的多重映射。该映射包含字符串和一对整数

std::multimap<string, std::map<string, std::pair<int, int>>> traders;
std::map<string, std::pair<int, int>> products;
std::pair<int, int> side;
std::多地图交易者;
地图产品;
std::对侧;
我通过以下方式向该多重贴图添加新值:

products.emplace(stringValue1, std::pair<int, int>(intValue1, intValue2));
traders.emplace(stringValue2, products);
products.emplace(stringValue1,std::pair(intValue1,intValue2));
贸易商就业(stringValue2,产品);
现在,我的问题来了。 我试图找到具有相同键值的交易者,然后读取每个找到的交易者的关联值。为了找到具有给定键值的交易者,我使用下面的代码,它是有效的

std::pair< 
    std::multimap<string, std::map<string, std::pair<int, int>>>::iterator, 
    std::multimap<string, std::map<string, std::pair<int, int>>>::iterator
> ret;
ret = traders.equal_range(stringKeyValue);
std::pair<
std::multimap::迭代器,
std::multimap::迭代器
>ret;
ret=交易者。相等范围(stringKeyValue);
我可以通过以下代码访问multimap的第一个值(字符串

std::multimap<string, std::map<string, std::pair<int, int>>>::iterator itr1 = ret.first;
std::cout <<  " " << itr1->first << std::endl;
std::multimap::迭代器itr1=ret.first;

也许这会有帮助。我还没有测试过

typedef std::map<string, std::pair<int, int> > TraderProductMap;
typedef std::multimap<string, TraderProductMap> TraderMap;

typedef TraderProductMap::iterator TraderProductMapIter;
typedef TraderMap::iterator TraderMapIter;

std::pair<TraderMapIter, TraderMapIter> range;
range = traders.equal_range(stringKeyValue);

for(TraderMapIter itTrader = range.first;itTrader != range.second;++itTrader) {

    std::cout <<  " " << itTrader->first << std::endl;

    for(TraderProductMapIter itProduct = itTrader->second.begin();itProduct != itTrader->second.end();++itProduct) {
        std::cout <<  "  " << itProduct->first << " " itProduct->second->first << " " << itProduct->second->second << std::endl;
    }

    std::cout << std::endl;

}
typedef std::map TraderProductMap;
typedef std::multimap TraderMap;
typedef TraderProductMap::迭代器TraderProductMapIter;
typedef TraderMap::迭代器TraderMap;
std::配对范围;
范围=交易者。相等的范围(stringKeyValue);
对于(TraderMapIter itTrader=range.first;itTrader!=range.second;++itTrader){
std::cout second.end();++itProduct){

std::cout first second“不能”是什么意思?我不得不稍微调整一下,但它为我指明了正确的方向。谢谢!