Hah, what a coincidence. I see that Hajo Kirchhoff has just asked basically the same question two hours before me. See "[Boost-users] [function] function_equal or function::operator== ambiguous overload?" Is this something which has changed in 1.36.0? Will go check with an older version... Best regards, Christian Christian Larsen skrev:
Hi,
I'm storing function objects in a std::vector, but to remove one again, I need to find an iterator to the one I want to remove. I do this in an "unregister" function taking a single boost::function
as parameter. Inside the function I would like to use the std::find algorithm to get an iterator to that function in the vector. I'm getting compile errors, though; see the example below. How do I fix these? I'm using MSVC++ 8 (SP1), and Boost 1.33.1 (can not upgrade).
Example, where in my "unregister" function I use find as in the last part of this example (i.e. I have a Listener and not a plain function pointer). This does not compile:
#include <algorithm> #include <vector> #include
using namespace std; using namespace boost;
void listenerA() {} void listenerB() {}
int main() { typedef function
Listener; typedef vector<Listener> ListenerVector; ListenerVector listeners;
listeners.push_back(&listenerA); listeners.push_back(&listenerB);
ListenerVector::iterator iter;
// This compiles and works iter = find( listeners.begin(), listeners.end(), &listenerB);
assert(iter != listeners.end());
// This gives: // error C2666: 'boost::operator ==' : 4 overloads have // similar conversions iter = find( listeners.begin(), listeners.end(), Listener(&listenerB));
assert(iter != listeners.end());
return 0; } [SNIP]