problem with bind2nd
Hi,
I am having the following question (see code below)
the class Data is declared as
class Data
{
public :
// rest of class
};
class Base : public binary_function<string, Data, bool>
{
public :
virtual bool operator() (const string& line, Data d) const = 0;
};
class Derived_1 : public Base
{
bool operator()(const string& line, Data d)
{
// do your stuff
return true or false;
}
};
class Derived_2 : public Base
{
bool operator()(const string& line, Data d)
{
// do your stuff
return true or false;
}
};
in some other class which has a vector dataLines I want to perform a find
on the vector. My problem is that sometimes I need to call the operator()
on the derived_1 class and another time I need to call operator() on the
Derived_2 class. The find function has a pointer to Derived_1 or Derived_2
class. But what do I put as argument for the bind2nd class
bind2nd( // What do i put here // , data)
I tried bind2nd( c() , data) but is gives me the error below
error C2064: term does not evaluate to a function taking 0 arguments
void MyClass::find(Compare* c, Data data)
{
vector<string>::iteraor result;
result = find_if(dataLines.begin(), dataLines.end(), bind2nd( // What do
i put here // , data));
// rest of code
}
Does anyone know how to fix this
thanks a lot
John