Returns an iterator pointing to the first element in the range [first, last] which does not compare less than val.
The elements in the range shall already be sorted or at least partitioned with respect to val.
ForwardIterator lower_bound (ForwardIterator first, ForwardIterator last, const T& val);
ForwardIterator lower_bound (ForwardIterator first, ForwardIterator last, const T& val, Compare comp);
The range used is [first, last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.
Value of the lower bound to search for in the range.
Binary function that accepts two arguments (the first of the type pointed by ForwardIterator, and the second, always val), and returns a value convertible to bool. The function shall not modify any of its arguments. This can either be a function pointer or a function object.
Return type :
An iterator to the lower bound of val in the range. If all the element in the range compare less than val, the function returns last.
Input : 10 20 30 40 50 Output : lower_bound for element 35 at index 3 Input : 10 20 30 40 50 Output : lower_bound for element 55 is index 5
Vector contains : 10 20 30 40 50 lower_bound for element 20 at position 1 lower_bound for element 55 at position 5
This article is contributed by Sachin Bisht. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Find the node whose sum with X has minimum set bits
- Salt and Pepper Noise removal using C++
- Dynamic Constructor in C++ with Examples
- C++ Stream Classes Structure
- OpenMP | Hello World program
- Odd Even Transposition Sort / Brick Sort using pthreads
- Chat application between two processes using signals and shared memory
- Find k closest numbers in an unsorted array
- Intel Graphics Software Engineer Interview Experience
- OpenMP | Introduction with Installation Guide
- Equation of straight line passing through a given point which bisects it into two equal line segments
- Maximum absolute difference in an array
- Count the pairs of vowels in the given string
- Why overriding both the global new operator and the class-specific operator is not ambiguous?
- Print path from root to all nodes in a Complete Binary Tree