Assume I have this IDL:
runtimeclass MyThing {
Windows.Foundation.IReference<UInt32> GetSize();
}
And my implementation says:
struct MyThing : MyThingT<MyThing> {
std::optional<uint32_t> m_sizeComputed;
winrt::Windows::Foundation::IReference<uint32_t> GetSize() {
if (!m_sizeComputed) {
return nullptr;
} else {
return winrt::box_value(m_sizeComputed.value()).as<winrt::Windows::Foundation<IReference<uint32_t>>>();
}
}
I'd like this to be easier on the implementation, where instead I can just say:
struct MyThing : MyThingT<MyThing> {
std::optional<uint32_t> m_sizeComputed;
const std::optional<uint32_t> GetSize() { return m_sizeComputed; }
}
Is there a way for C++/WinRT's shims to match up IReference<T>-things (properties, returned types, parameters) and auto-convert them to/from std::optional<T>?