count — count exact value. count_if — count with predicate.
std::count:
1std::vector<int> v = {1, 2, 2, 3, 2, 4};2int c = std::count(v.begin(), v.end(), 2);3// c = 3
std::count_if:
1// Count even numbers2int c = std::count_if(v.begin(), v.end(),3 [](int x) { return x % 2 == 0; }4);5// c = 4 (2, 2, 2, 4)
Return type: