Problem using templated predicate in STL algorithms
问题 I have the following piece of code, that gives an error on the first usage form of pred2. I was hoping if someone could explain why this particular usage is incorrect, as I think pred3 usage is similar. #include <algorithm> bool pred1(const int&) { return true; } template<typename T> bool pred2(const T&) { return true; } struct pred3 { template<typename T> bool operator()(T&) { return true; } }; int main() { int A[] = { 2, 0, 4, 6, 0, 3, 1, -7 }; const int N = sizeof(A) / sizeof(int); std: