Following is my code for creating a map<int, vector<int>> and printing:
//map<int, vector>
map<int, vector<int>> int_vector;
vector<int> vec;
vec.push_back(2);
vec.push_back(5);
vec.push_back(7);
int_vector.insert(make_pair(1, vec));
vec.clear();
if (!vec.empty())
{
cout << "error:";
return -1;
}
vec.push_back(1);
vec.push_back(3);
vec.push_back(6);
int_vector.insert(make_pair(2, vec));
//print the map
map<int, vector<int>>::iterator itr;
cout << "\n The map int_vector is: \n";
for (itr2 = int_vector.begin(); itr != int_vector.end(); ++itr)
{
cout << "\t " << itr->first << "\t" << itr->second << "\n";
}
cout << endl;
The printing part does not work because of the
error: C2678: binary '<<': no operator found which takes a left-hand operand of type
'std::basic_ostream<char,std::char_traits<char>>' (or there is no acceptable conversion)