For the past few days, I’ve been talking about converting between various string types while avoiding data loss and security issues if an embedded null is present. But in the case where you are dealing with winrt::
and std::
, the story is much simpler.
The winrt::
and std::
types can simply be assigned to each other. No need to do funny wstring_view
or c_str()
nonsense.
winrt::hstring h; std::wstring s; h = s; // this works! s = h; // this also works!
The assignments work because winrt::
and std::
both support assignment from std::
, and both winrt::
and std::
are convertible to std::
.
So what you’re saying is that two of each of yesterday’s function bodies could have been
return s;
orreturn v;
as appropriate?