Publish a complete program that does not compile. This compiles fine:
#include <list> #include <algorithm> #include <iostream> struct Foo { std::list<int> ml; bool search(int x) const { return std::find(ml.begin(), ml.end(), x) != ml.end(); } }; int main() { const Foo f; std::cout << f.search(0) << "\n"; }
Maybe find does not call a function that you think is [Edit: more likely stupid of me, myList is not std::list ]. Reducing to a small program that demonstrates the problem is likely to reveal the cause, because at some point you will remove something and it will start working.
source share