I want to insert an integer value and a pair in a multiset.
So I declared it as:
multiset < int, pair < int, int> > mp;
int m,n,p;
To insert in multiset I tried this :
mp.insert(make_pair(m, make_pair(n,p))); // Compile time error
But its giving compile time error… Could someone please suggest the correct method to implement it.
The type
multiset<int,pair<int,int>>is trying to create a multiset where the Key isintand the Compare ispair<int,int>. This is nonsensical. You either want to useor you want to use
The former type (
pair<int,pair<int,int>>) matches the expression you’re using to insert into the set (make_pair(m, make_pair(n,p))). If you use the latter, you’ll wantmake_tuple(m,n,p).