The pai_range Algorithm in STL returns a pair value range,
Vector <int> vec;
... // Vec initialize
Pair <vector <int >:: iterator, vector <int >:: iterator> range;
Range = pai_range (vec. begin (), vec. end (), value );
Range. first is the position of the smallest iterator that can insert values without changing the original sorting order, range. second is the maximum iterator location where values can be inserted without changing the original sorting order.
Actually, if value exists in vec, range. first is the iterator in vec pointing to the first value position, and range. second is the iterator pointing to the first position greater than the value in vec. if the search value is the last value in the container, range. second is container. end (). if there is no value in vec, range returns a 0 range, that is, range. first = range. second = point to the iterator (which may be vec) where the first value is greater than value. end, if all values in vec are smaller than value ).
Description on sgi.
Note that every _range may return an empty range; that is, it may return a pair both of whose elements are the same iterator.
Performance_range returns an empty range if and only if the range [first, last) contains no elements equivalent to value.
In this case it follows that there is only one position where value cocould be inserted without violating the range's
Ordering, so the return value is a pair both of whose elements are iterators that point to that position.
Description on http://www.cplusplus.com/reference/algorithm/equal_range/
If value is not equivalent to any value in the range, the subrange returned has a length of zero, with both iterators
Pointing to the nearest value greater than value, if any, or to last, if value compares greater than all the elements
In the range.
(However, relevant instructions are not found in the "c ++ standard library self-repair Tutorial and Reference Manual". It should be reasonable to say that there should be instructions, maybe they did not see them too quickly .)
It can be seen from the above that no value exists in vec. If you want to insert the value into vec, you can use range. insert second position (regardless of range. whether second points to), but for other purposes, consider the range when the value does not exist in the container. first = range. second.