I would like to remove an object from a vector based on a lambda predicate:
class tmr { public: tmr(); ~tmr(); static void start(); bool is_time_out(double sec); double t_elapsed(); }; struct sobj { int count; bool tflag; int ID; tmr timer; friend bool is_stime(timer& objtimer,double sec) { return objtimer.is_time_out(sec); } }; somewhere in the main program, I populate a vector<sobj>, then after some time, I want to remove the element whose ID is specified and whose timer has elapsed.
I did this , and it complains about not being able to convert void to bool
sobj strobj; vector<sobj> vecobj; vecobj.erase(std::remove_if(vecobj.begin(),vecobj.end(),[&](const sobj& mysobj){return ( mysobj.ID== THE_ID && mysobj.is_stime(mysobj.timer,5));}),vecobj.end());
foo.cc:11:16: error: use of undeclared identifier 'is_sobj's/^/ /assuming your editor is vi), and edit it into your post.