If you mean the use of tools for linking the functions of the standard library, then at least not in C ++ 98. In C ++ 11, you can use std::bind for an arbitrary composition of functors:
using std::placeholders; int count = std::count_if(v.begin(), v.end(), std::bind(std::logical_and<bool>(), std::bind(std::less<int>(), _1, 3), std::bind(std::greater<int>(), _1, 0)));
But it really does not give a headache for such a simple predicate.
If the capabilities of C ++ 11 are enabled, then the simplest way is likely to be lambda, there is no need to create a complex composition (on its own):
int count = std::count_if(v.begin(), v.end(), [](int arg) { return arg > 0 && arg < 3; });
But for C ++ 98 Chubsdad, the answer is probably the best solution.
source share