Hello,
Could you please tell me how to compare two boost::function objects
packet with boost::ref. I have container which has boost::function
elements and to add elements is not a problem but to remove particular
one I don't know how to do that (compare two boost:ref-s). The problem
is shown in the code below.
Regards,
Bartek
//code
#include <iostream>
#include <list>
#include
#include
struct test{
int a;
void operator() (int aa)
{ a += aa; }
};
struct function_list {
std::list > fun_list;
void add(boost::function fun)
{
fun_list.push_back(fun);
}
void remove(boost::function fun)
{
std::list >::iterator iter;
//HOW TO IMPLEMETN THIS FIND_IF?
//std::find_if(fun_list.begin(), fun_list.end(), MISSING_PART);
if(iter != fun_list.end())
fun_list.erase(iter);
}
};
int main(int argc, char **argv) {
test a, b;
function_list f;
f.add(boost::ref(a));
f.add(boost::ref(b));
//DOES NOT WORK
f.remove(boost::ref(a));
}