cpp/algorithm/equal range

Returns a range containing all elements equivalent to in the range.

The range must be at least partially ordered with respect to, i.e. it must satisfy all of the following requirements: A fully-sorted range meets these criteria.
 * partitioned with respect to or  (that is, all elements for which the expression is  precedes all elements for which the expression is )
 * partitioned with respect to or
 * for all elements, if or  is  then  or  is also

The returned range is defined by two iterators, one pointing to the first element that is not less than and another pointing to the first element greater than. The first iterator may be alternatively obtained with std, the second - with std.

The first version uses to compare the elements, the second version uses the given comparison function.

Return value
A std containing a pair of iterators defining the wanted range. The first pointing to the first element that is not less than and the second pointing to the first element greater than.

If there are no elements not less than, is returned as the first element. Similarly if there are no elements greater than, is returned as the second element.

Complexity
The number of comparisons performed is logarithmic in the distance between and  (At most $2 * log 2(last - first) + O(1)$ comparisons). However, for non-s, the number of iterator increments is linear. Notably, std and std iterators are not random access, and so their member functions std (resp. std) should be preferred.