If I have a UUID defined somewhere in the source code:
class DECLSPEC_UUID("31A0884B-2B2F-4243-B4A0-2AEFE11FDD68") MyGuidClass;
Is there a way to use it for a static const C-string declaration? (Microsoft-specific.)
In this kinda form:
static LPCWSTR kstrKeys[] =
{
__uuidof(MyGuidClass), //instead of this: L"31A0884B-2B2F-4243-B4A0-2AEFE11FDD68",
};
__uuidofdoes not return a string, but rather a GUID in binary form. But, it is possible to convert this GUID to a string at compile-time. I usestd::arrayto store the string data in, because that'sconstexpr(even in C++17):