c++ - reversing values in two multimaps -
#include <map> #include <iostream> #include <string> using namespace std; // dwa 1 // dwa 4 // jeden 1 // jeden 2 // piec 5 int main() { multimap1<string,int>; multimap2<int,string>; return 0; }
for code, how 1 can assign multimap 2 multimap 1 , recieve expected input(commented section of code)
something following :
std::multimap<int,std::string> src; std::multimap<std::string,int> dst; std::transform(src.begin(), src.end(), std::inserter(dst, dst.begin()), [] (const std::pair<int,std::string> &p) { return std::pair<std::string,int>(p.second, p.first); } );
see here
Comments
Post a Comment