C++ algorithm count_if
Date: 2022-12-13Last modified: 2023-02-13
Table of contents
std::array<int, 4> arr{ 1, 2, 3, 4 };
auto res = std::count_if( arr.cbegin(), arr.cend(), []( int x ) { return x == 3; } );
std::cout << "There are " << res << " number of elements equal to 3" << std::endl;
Possible output
There are 1 number of elements equal to 3