Pair<set<int>::iterator, bool> ret;

When we declare ret = set.insert(10)
why does the ret.second return 0;

set.insert(someValue) return a pair, with its member pair::first set to an iterator pointing to either the newly inserted element or to the equivalent element already in the set. The pair::second element in the pair is set to true if a new element was inserted or false if an equivalent element already existed.

so since we already had inserted 10 before so s.insert(10) returned a pair in which first is the iterator pointing to this element and second is false since 10 was already present
that’s why we got 0 as ret.second

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.