我得到的 C++ 编译器错误是:
line 27: Error: Could not find a match for
std::multimap<std::string, std::vector<std::string>,
std::less<std::string>,
std::allocator<std::pair<const std::string,
std::vector<std::string>>>>
::insert(std::pair<std::string, std::vector<std::string>>)
needed in main().
1 Error(s) detected.
下面是我的程序:
#include<iostream>
#include<sstream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
typedef multimap<string, vector<string> > mos_map;
typedef multimap<string, vector<string> >::iterator mos_map_it;
int main()
{
mos_map mos;
mos_map_it it;
vector<string> v1;
v1.push_back("a");
v1.push_back("b");
v1.push_back("c");
v1.push_back("mo1");
std::string a(*(v1.end()-1));
mos.insert(std::pair< std::string, vector< std::string > >(a,v1));
//Is the above not the right way to to insert an element into the map?
return 0;
}
当我尝试以字符串作为键插入向量作为值时,上面的代码引发编译错误。我正在使用 solaris。