
Hello all,I've a class with boost::variant as its member ; class A { public: A() { } boost::variant<int, string, double, date>& getValue (const string& key) { ... } private: map<string, boost::variant<int, string, double, date> >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

On Sun, Mar 1, 2009 at 11:17 AM, Surya Kiran Gullapalli <suryakiran.gullapalli@gmail.com> wrote:
Hello all, I've a class with boost::variant as its member ; class A { public: A() { }
boost::variant<int, string, double, date>& getValue (const string& key) { ... } private: map<string, boost::variant<int, string, double, date> >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<int, string, double, date> lookFor(1); using namespace boost::lambda; find_if(myList.begin(), myList.end(), constant(lookFor) == bind(&A::getValue, _1, "SomeKey") == 1)); Stuart Dootson
participants (2)
-
Stuart Dootson
-
Surya Kiran Gullapalli