I have a structure like this.
struct A
{
int someFun() const;
int _value;
};
I store objects of this structure in a vector.
-
How to find the object whose member
someFun()returns42? -
How to find the object whose
_valueis42?
I guess I have to use the combination of bind and equal_to, but I’m not able to find the right syntax.
vector<A> va;
vector<A>::const_iterator val = find_if(va.begin(),va.end(),boost::bind(???,42));
Edit:
Thanks. But one more doubt.
What if I had vector<A*> or vector<boost::shared_ptr<A> >?
In case you do need to compose bind expressions (e.g. using a
functorthat cannot be expressed with the operators supported byboost::bind):which results in a call to
functor::operator()with arguments as follow: the result of calling the member on the argument to the bind expression, and 42.