|
Boost Users : |
Subject: [Boost-users] Question in usage of boost::bind
From: Archie14 (admin_at_[hidden])
Date: 2009-02-02 13:29:27
Below is an example that fails to compile. I have a vector of pointers to a
templated class and I need to use find_if. My understanding of boost::bind. is
that the first argument, when binding member function, is an explicit "this"
pointer,
that should be A* in my case.
Any help in explaining what I am doing wrong will be greatly appreciated.
#include <algorithm>
#include <string>
#include <vector>
#include <boost/bind.hpp>
#include <algorithm>
#include <string>
#include <vector>
#include <boost/bind.hpp>
template<typename T> class A
{
T _val;
public:
A(T val) : _val(val){};
T Val() {return _val;}
bool CompareByVal(A<T>* a, int iType, T ofval)
{
return ( (a != NULL) && (iType == 1) && (a->Val() == ofval) );
}
};
int _tmain(int argc, _TCHAR* argv[])
{
std::vector<A<int>*> a;
std::find_if (a.begin(),
a.end(),
boost::bind(&A<int>::CompareByVal, _1, _2, 1,1));
}
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net