I've asked a similar question already but did not provide enough details. So I'm trying to re-phrase it with a better code sample. So here it is.
First off I'm using Visual Studio 2008 C++ compiler and I'm trying to implement a template to call a member method of a class.
The template is declared as such:
typedef void (*ON_CALL)(HWND);
template <typename CLASS, ON_CALL F>
class CMyTemplate
{
public:
static void onProcess(CLASS* pDlg)
{
pDlg->SetTimer(100, 1, _onTimer);
}
private:
static void WINAPI _onTimer(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
KillTimer(hwnd, idEvent);
CLASS* pDlg = (CLASS*)CDialog::FromHandle(hwnd);
if(pDlg)
{
pDlg->F(hwnd);
}
}
};
And it's actually called like so:
void CMyDialog::SomeMethod()
{
CMyTemplate<CMyDialog, OnCall>::onProcess(this); //error C2975
}
void CMyDialog::OnCall(HWND hWnd)
{
//Do work ...
}
But that line that I marked above gives me this error:
error C2975: 'F' : invalid template argument for 'CMyTemplate', expected compile-time constant expression