You can't figure it out because you can't do this.
The elements in a set are "complete" elements. Just because you see a std::pair in there, and you think that the set contains two elements, it doesn't mean that it is. The set contains a std::pair
, a single, complete, element.
If you have another std::pair
, somewhere, you can search the set to see if there's an equivalent pair in there. But if you only have half of the object that the set contains, you really can't do it.
The only options I see here are:
iterate over the set manually, until you do or do not find what you're looking for.
If there's a minimum int
value you expect to be in there, you can use lower_bound()
, passing a std::pair
with the minimum value for the int
portion, and the string you're search for, and see what lower_bound()
digs up.
perhaps reconsider your decision to use a std::set
for whatever purpose you're using. Perhaps a std::set
, containing a std::pair
, isn't really the appropriate container for your requirements.