#include <set>
    pair<iterator, iterator> equal_range( const key_type& key );
    pair<const_iterator, const_iterator> equal_range( const key_type& key ) const;

The function equal_range() returns two iterators - one to the first element that contains key, another to a point just after the last element that contains key. In set containers, where no duplicate keys are allowed, the range will include one element at most.

If key does not match any key in the container, both the returned pointers point to nearest value greater than key, if any, or to set::end if key is greater than all the elements in the container.


// set::equal_elements
#include <iostream>
#include <set>
using namespace std;
int main ()
  set<int> myset;
  pair<set<int>::iterator,set<int>::iterator> ret;
  for (int i=1; i<=5; i++) myset.insert(i*10);   // set: 10 20 30 40 50
  ret = myset.equal_range(30);
  cout << "lower bound points to: " << *ret.first << endl;
  cout << "upper bound points to: " << *ret.second << endl;
  return 0;