hi, expert. i find that we can define a function pointer for template
argument.
for exmaple:
template<typename void(*err_handle)()> class List{/*...*/};
...
void err_handler1()
{};
...
List<int, &err_hander1> x1; // OK........
now, my question is we can define a pointer that point to non-static member
function? i have tested 2 cases:
Case 1.
template<typename T, void (T::*pfuncType)(const T& ) > class a_t {};
class b
{
public:
void non_virtual(const b& ) {};
virtual void test_virtual(const b& ) {};
protected:
private:
};
a_t<b,&b::non_virtual> g_non_virtaul;
a_t<b,&b::test_virtual> g_test_virtaul;
compile it successfully!
Case 2.
template<typename T, void (T::*pfuncType)(const T& ) > class a_t {};
class b
{
public:
void non_virtual(const b& ) {};
virtual void test_virtual(const b& ) {};
a_t<b,&b::non_virtual> m_non_virtaul;
a_t<b,&b::test_virtual> m_test_virtaul;
protected:
private:
};
I can not compile it, why?
the error message is error C2327: 'b::non_virtual' : member from enclosing
class is not a type name, static, or enumerator