Let say I have the following code:
template<typename T> Matrix{
private:
int nr;
std::vector<T> data;
public:
T& operator()(const int& j, const int& k){
return this->mat.at(j+k*nr);}
const T& operator()(const int& j, const int& k) const {
return this->mat.at(j+k*nr);}
};
At some point I need to create a function pointer associated to const T& operator()(const int& j) const to use it as an argument in another function. Using functional, I tried:
//#include<functional>
function<const double&(const Matrix<double>&, const int&, const int&)> coef=&Matrix<double>::operator();
and I have the following error:
no viable conversion from '<overloaded function type>' to 'function<const double &(const
Matrix<double> &, const int &, const int &)>
I cannot get it to work and it is pretty hard to find informations on function, since the name is quite used...
EDIT
As pointed out in the comment section, it is not a duplicate and I don't think I should you use bind. I am just trying to apply the last example in http://www.cplusplus.com/reference/functional/function/function/ where they add a reference argument in the function pointer for a member function. The difference here is that my function member is an operator and I have not succeeded in doing the same as in the example. So, is there a syntax problem in what I am doing ? or may there is a subtlety with operators ?