lower_bound<>
: On Sorted Sequence¶
More Intelligent Search¶
Result: Pointer/iterator to element found or past
⟶ very flexible
std::vector<int> int_array;
int_array.push_back(7);
int_array.push_back(42);
int_array.push_back(42);
int_array.push_back(666);
std::vector<int>::const_iterator lower =
std::lower_bound(int_array.begin(), int_array.end(), 42);
while (lower != int_array.end() && *lower == 42) {
std::cout << *lower << std::endl;
++lower;
}