How to get the iterator for a successful binary_search?

nakiya picture nakiya · Nov 22, 2010 · Viewed 11.8k times · Source

I want to get the iterator for the element I'm testing for in binary-search. But it only returns a bool indicating whether it found the value or not. How to get the iterator?

Answer

CTT picture CTT · Nov 22, 2010

You want either lower_bound, upper_bound, or equal_range.