Click here to Skip to main content
Click here to Skip to main content

Tagged as

Go to top

Passing a const character * as a template argument

, 29 Jun 2011
Rate this:
Please Sign up or sign in to vote.
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;
                                                                

License

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

Share

About the Author

Mukit, Ataul
Chief Technology Officer Rational Technologies
Bangladesh Bangladesh
You don't learn patterns, you just code it.
Follow on   Twitter

Comments and Discussions

 
GeneralBy the way symbol that starts with an underscore are usually... PinmemberPhilippe Mori30-Jun-11 14:11 
GeneralTrying to do that might also result in code bloat... It also... PinmemberPhilippe Mori30-Jun-11 13:52 
GeneralHi Ataul, could you elaborate a bit on where you would use s... PinmemberDoc Lobster29-Jun-11 21:15 
GeneralRe: Thanx for pointing out the mistake, I removed the str which ... PinmemberMukit, Ataul29-Jun-11 22:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140922.1 | Last Updated 30 Jun 2011
Article Copyright 2011 by Mukit, Ataul
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid