Hello @Shyam Butani ,
Welcome to Microsoft Q&A!
It means it's keeping the reference of the same hstring instead of copying the whole string data, right?
Yes, winrt::hstring
just inlines this into its implementation and takes care of bumping the internal reference count when copies are made or allocating when fast-pass strings are copied.
So my doubt is, it is guaranteed that the memory allocated by label will not get de-allocated even after label is destroyed, because label_copy is holding the same memory address?
Yes, because the reference count is greater than 0. If the reference count drops to zero, then the string is destroyed.
For detail information please refer to Raymond’s complete guide to HSTRING semantics.
Thank you.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.