I have an unordered set of pair of integers maintained by the hash of the first value of pair. insert() function of unordered set returns an iterator to the currently inserted element. Now is there any way to use that iterator and update the second value of the inserted pair as it is not used for computing hash as I mentioned in the comment
struct hasher
{
public:
size_t operator()(const pair<int, int> & a) const {
return std::hash<int>()(a.first); }
};
struct comparer
{
public:
bool operator()(const pair<int, int>& a, const pair<int, int>& b) const {
if (a.first == b.first)
return true;
else
return false;
}
};
unordered_set<pair<int, int> , hasher, comparer> st;
int main() {
auto tmp = st.insert({1,2}); // this returs a pair of iterator pointing to currently inserted element and boolean value representing whether inserted or not
//(*(tmp.first)).second = 3; <- I want this part to work
}