Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C++

Passing a const character * as a template argument

5.00/5 (2 votes)
29 Jun 2011CPOL 34.9K  
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[^]

C++
template<class _Ty, const wchar_t* ptr> 
struct CVHDialogTmpl
{     
	CVHDialogTmpl()
	{
	}     

	INT_PTR DoModal()
	{
		return t.DoModal(ptr);
	}
	
	_Ty t;
}; 


C#
class VHRes
{
public:
    static const wchar_t name[];
};

const wchar_t VHRes::name[] = L"XMLDlgPrj.xml";


C++
CVHDialogTmpl<CXMLDlgPrjDlg, VHRes::name> dlg;

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)