I have a map like this
map<string, pair< pair<int, int>, string> >
what is the easiest way to get only the two strings and save into another map like this
map<string, string>
?
I mean is there another way other than something like this??
map<string, pair< pair<int, int>, string> > info;
map<string, pair< pair<int, int>, string> >::iterator i;
map<string, string> something;
for(i=info.begin(); i!=info.end(); ++i)
something[*i).first] = ((*i).second).second;
First, I’d define a proper type:
There are almost no cases where
std::pairis an acceptable solution(except for quick hacks and tests). Given that, you define a mapping
functional object:
, then use
std::transform: