I have the following mapped multimap :
map<int, multimap<int, pair<string, string>>> modCreAlt;
I am trying to insert a line in it :
int priority = ... ;
string alertInv = ... ;
string upperAlertInv = ... ;
modCreAlt.insert(make_pair(42, make_pair(priority, make_pair(alertInv, upperAlertInv))));
But I get the following compilation error :
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\utility(49):
error C2664: 'std::multimap<_Kty,_Ty>::multimap(const std::less<_Kty> &)' :
cannot convert parameter 1 from 'const std::pair<_Ty1,_Ty2>' to 'const std::less<_Ty> &'
----
I also tried to insert a line that way :
modCreAlt.insert(pair<int, multimap<int, pair<string, string>>>(42, make_pair(priority, make_pair(alertInv, upperAlertInv))));
And :
modCreAlt[42] = make_pair(priority, make_pair(alertInv, upperAlertInv));
which results in, respectively, the 2 following compilation errors:
error C2665: 'std::pair<_Ty1,_Ty2>::pair' : none of the 3 overloads could convert all the argument types
And :
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'std::pair<_Ty1,_Ty2>' (or there is no acceptable conversion)
Like this perhaps (untested)
int priority = ... ;
string alertInv = ... ;
string upperAlertInv = ... ;
modCreAlt[42].insert(make_pair(priority, make_pair(alertInv, upperAlertInv)));
Using [] creates an empty multimap for you (assuming one doesn't already exist at 42).