Facing issue with deletion of last element in set :
#include <bits/stdc++.h>
using namespace std;
int main()
{
set < pair <int,int > > a;
a.insert(make_pair(2,3));
auto it = a.rbegin();
a.erase(it.base()); // for deleting last element in set
cout << a.size() << endl;
return 0;
}
Getting the runtime issue, Also have tried with auto, Iterator and Const iterator, it's not working.Is there any other way to erase an element from a set ?
Edit : How can I delete a Particular element based on iterator reference ? if i do like :
auto it=a.begin();
a.erase(it); Here it = reference to the element for deletion
it doesn't work.Any other way to delete based on iterator reference ?