I've got this class:
template <class T>
class list
{
...
bool moreThan(T x, T y);
bool lessThan(T x, T y);
...
};
I need a function pointer to change the behavior of my class, and switch between using bool moreThan(T, T)
or bool lessThan(T, T)
.
So I'm currently using:
bool (list<int>::*foo)(int x, int y);
foo = &list<int>::lessThan;
and to use it:
(this->*foo)(x, y);
but I would like to have a flexible function pointer, so that I can use it with whichever T
I need, not just int
. So is there a way to create a function pointer to a class template member? Something like:
template <class T>
bool (list<T>::*foo)(T x, T y); //this doesn't work