I have a member function as follows:
class XYZ{
public:
float function(float x);
private:
float m_DensityMin;
float m_DensityMax;
};
Now I am trying to convert std::vector<float> foousing the std::transformSTL algorithm by passing a member function functionand storing the resulting values in a vector bar.
If I use this function as a global function, with random data that class member variables should indicate, it works fine.
However, since a function requires the use of member variables m_DensityMinand a m_DensityMaxclass, I need to use it as a member function. This is what I tried:
std::transform(foo.begin(), foo.end(), bar.begin(), &XYZ::function);
but in the end I get an error in VS2010:
error C2065: term does not evaluate to a function taking 1 arguments
, . ?
question, std:: mem_fun, std:: mem_fn , .