find — exact match. find_if — predicate match.
std::find:
1std::vector<int> v = {1, 2, 3, 4, 5};2auto it = std::find(v.begin(), v.end(), 3);3if (it != v.end()) {4 std::cout << "Found: " << *it << "\n";5}
std::find_if:
1// Find first even number2auto it = std::find_if(v.begin(), v.end(),3 [](int x) { return x % 2 == 0; }4);56// Find with struct7struct IsEven {8 bool operator()(int x) const {9 return x % 2 == 0;10 }11};12auto it2 = std::find_if(v.begin(), v.end(), IsEven());
Variants:
find_if_not — negated predicate.find_end — find subsequence.find_first_of — find any of set.