bool isEven(int val) {
return val % 2 == 0;
}
bool isOdd(int val) {
return val % 2 != 0;
}
template<class Iterator>
int count_function(Iterator start, Iterator end, auto criteria) {
int count = 0;
for (; start != end; ++start) {
if (criteria(*start)) {
count++;
}
}
return count;
}
Above is my code, auto before criteria is giving error "auto is now allowed here". I want to supply isEven /isOdd criteria to this function.
Why is that?
I have tried int, bool - that return some more problem.