Passing a const character * as a template argument





5.00/5 (2 votes)
This tip shows you how to pass a const char* or const wchar_t* as a template argument
Many many thanks to DeadMG stack overflow
http://stackoverflow.com/questions/3773378/passing-const-char-as-template-argument[^]
template<class _Ty, const wchar_t* ptr>
struct CVHDialogTmpl
{
CVHDialogTmpl()
{
}
INT_PTR DoModal()
{
return t.DoModal(ptr);
}
_Ty t;
};
class VHRes
{
public:
static const wchar_t name[];
};
const wchar_t VHRes::name[] = L"XMLDlgPrj.xml";
CVHDialogTmpl<CXMLDlgPrjDlg, VHRes::name> dlg;