Something went wrong. Try again.
A Tour of C++ for experienced programmers, as if C++26 is the only version that ever existed.
Something went wrong. Try again.
12345678910111213141516171819#include <vector>#include <algorithm>#include <print>
int main() { std::vector<int> v{5, 2, 9, 1, 5, 6}; std::sort(v.begin(), v.end()); std::println("sorted:"); for (int n : v) std::print("{} ", n); std::println(""); int key = 5; auto it = std::lower_bound(v.begin(), v.end(), key); if (it != v.end() && *it == key) std::println("lower_bound of {} is at index {}", key, std::distance(v.begin(), it)); else std::println("key not found"); return 0;}