-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wil should add GUID-related APIs #362
Comments
IMO - if you're trying to heap allocate a
I could see something like: template <typename StringT>
HRESULT to_string_nothrow(const GUID&, StringT&);
template <typename StringT>
StringT to_string(const GUID&); for these scenarios as quick helpers for the rare times where this is needed. |
And also a template<typename TGuid = GUID> create_guid()
{
GUID g;
THROW_IF_FAILED(::CoCreateGuid(&g));
return { g };
} (No nonthrowing variant required since |
to implementer: consider that GUIDs have two forms -- with and without surrounding braces, so it would be nice if this implementation also supported this. PowerShell does a good job IMO: > [Guid]'23f1dd41-a85f-4b5c-8ce0-010bd2f886f7'
Guid
----
23f1dd41-a85f-4b5c-8ce0-010bd2f886f7
> [Guid]'{23f1dd41-a85f-4b5c-8ce0-010bd2f886f7}'
Guid
----
23f1dd41-a85f-4b5c-8ce0-010bd2f886f7
> ([Guid]'{23f1dd41-a85f-4b5c-8ce0-010bd2f886f7}').ToString()
23f1dd41-a85f-4b5c-8ce0-010bd2f886f7 And would be nice to get to underlying struct as well, so one could access the underlying fields of the GUID struct if needed. |
See also the work I did on the static_sid type, which returns a custom type of "the right size." So you could define a new |
WIL has these constants:
but no complementary APIs to do conversion to/from std::string. Plus things for CoCreateGuid, format to/from strings, etc. I know many teams end up using cppwinrt's helpers to do this instead.
The text was updated successfully, but these errors were encountered: