Hi,
I'm using the STL function count_if to count all the positive values in a vector of doubles. For example my code is something like:
vector<double> Array(1,1.0)
Array.push_back(-1.0);
Array.push_back(1.0);
cout << count_if(Array.begin(), Array.end(), isPositive);
where the function isPositive is defined as
bool isPositive(double x)
{
return (x>0);
}
The following code would return 2. Is there a way of doing the above without writting my own function isPositive? Is there a built-in function I could use?
Thanks!