C++ 23 · Containers and algorithms

Find the first match

Search with a predicate. The result is an iterator, end() if nothing matches.

auto it = std::find_if(v.begin(), v.end(), [](int n) { return n > 10; });
if (it != v.end()) std::cout << *it << '\n';

Official C++ 23 documentation

More containers and algorithms commands

All containers and algorithms commands · C++ 23 cheatsheet

Was this page helpful?