how to insert pair values in a map into a normal map

So if I have a map m1 that has pairs of <string,pair<string,int>>, how do I 'extract' the value of m1's pairs and put them into a new map m2 so that I have normal pairs like <string, int>?

Accessing m1's value like m1.second.first (to get the key of m1's value pair) is wrong according to my ide and I don't know where to search to figure out how to do this properly.

Maybe something like this:
1
2
3
4
    for (std::map<string,pair<string,int>>::iterator it=m1.begin(); it!=m1.end(); ++it)
    {
        m2.insert(it->second);
    }


or this:
1
2
3
4
    for (const auto &x  : m1)
    {
        m2.insert(x.second);
    }
Topic archived. No new replies allowed.