Why is there no corresponding function for my mem_fun_ref call?

I have code in which classes inherit from a base class.

This base class has a function that, when launched, must call functions that will be executed by children. That is, the general algorithm is the same for all children, but the implementation of the steps should be different.

template<class T>
class Foo
{
    public:
        Foo(T y):y(y) { for(int i; i < 10; ++i) x.push_back(i); };
    protected:
        virtual bool IsOk(T, int)=0;
        void Run()
        {
            vector<int>::iterator it, bound;
            for(int i; i < 10; ++i)
            {
                cout << "step " << i << endl;
                bound = partition(x.begin(), x.end(), bind2nd(mem_fun_ref(&Foo<T>::IsOk), i));
                for (it=x.begin(); it!=bound; ++it)
                    cout << "  " << *it;
            };
        };
    private:
        vector<int>x;
        T y;
};

class Bar : public Foo<int>
{
    public:
        Bar():Foo<int>(50){this->Run();};
        bool IsOk(int x , int y) {return x == y;}

};

However, when I do this, the following error message appears: no matching function for call to 'mem_fun_ref(bool (Foo<int>::*)(int, int))'

Can someone give me some idea of ​​what I have been doing for a long time?

+3
source share
2 answers

Below are the prototypes for mem_fun_ref

template <class S, class T>
  mem_fun_ref_t<S,T> mem_fun_ref (S (T::*f)());

template <class S, class T, class A>
  mem_fun1_ref_t<S,T,A> mem_fun_ref (S (T::*f)(A));

template <class S, class T>
  const_mem_fun_ref_t<S,T> mem_fun_ref (S (T::*f)() const);

template <class S, class T, class A>
  const_mem_fun1_ref_t<S,T,A> mem_fun_ref (S (T::*f)(A) const);

Your mem_fun_ref(bool (Foo<int>::*)(int, int))dosnt matches any of these and therefore an error.

0
source

mem_fun_ref , . , , boost::bind ( ++ 0x).

+3

All Articles