C ++ a simple way to convert a macro variable to wchar string literal

In the following example, I would like to remove the std::wstring(std::widen(...)) , but macroC ## returns only the char string literal - is there a way to place wchar?

 #define FOO_MACRO(className)\ struct className##Factory : public OtherClass {\ // does some stuff here\ } className##Factory;\ someMap->add(std::wstring(std::widen(#className), className##Factory))) 

How would I do the same using wchar?

+4
source share
1 answer

You use the L prefix in a string literal to create a wchar string literal:

 #define CAT(A, B) A##B #define WSTRING(A) CAT(L, #A) 
+7
source

All Articles