Lower bound and upper bound of C++

Jimmy (xiaoke) Shen
3 min readFeb 4, 2020

Lower bound and upper bound in STL

  • upper_bound() and lower_bound() are standard library functions in C++.
  • upper_bound() returns an iterator pointing to the first element in the range [first, last) that is greater than the value. If no such an element is found, return end().
  • lower_bound() returns an iterator pointing to the first element in the range [first, last) which is greater or equal to the value. If no such an element is found, return end().

Quick summary

--

--