On Sun, Mar 1, 2009 at 11:17 AM, Surya Kiran Gullapalli
wrote:
Hello all,
I've a class with boost::variant as its member ;
class A
{
public:
A() { }
boost::variant& getValue (const string& key)
{
...
}
private:
map >m_member ;
}
I've list of A's like this
list<A> myList.
when trying to find a particular element with integer value (1 say) which is
stored in m_member,
I'm doing this..
find_if (myList.begin(), myList.end(),
(boost::lambda::bind(&A::getValue, boost::lambda::_1, "SomeKey") == 1));
This is giving lot of errors. I've tried casting the result of bind to
Variant, and then converting the variant to int using boost::get<int>()..
but no help.
Any ideas how to do this ?
Surya
How about comparing variants rather than try to extract a value that
may not be an int anyway?
boost::variant lookFor(1);
using namespace boost::lambda;
find_if(myList.begin(), myList.end(), constant(lookFor) ==
bind(&A::getValue, _1, "SomeKey") == 1));
Stuart Dootson