Christian Larsen skrev:
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?
Sorry for spamming the list. I think I found a solution to my original
problem. But still I'm not completely satisfied, because it seems there
is no way I can store the function objects and use those for both adding
and later removing. If I try to store them using boost::function I get
the same error as before when calling either Source::add or
Source::remove, obviously because std::find tries to compare two
boost::function's internally.
This example does what I expect, but would it somehow be possible to
store the bind(&listenerA, 42) for later use in the remove call? (Having
to write the same in both places is error prone.)
#include <algorithm>
#include <iostream>
#include <vector>
#include