I have C/C++ SDK library which should be ported to Windows 8 Metro (WinRT). Library is mostly OS-independent, but it contains some modules which interact with hardware using OS-provided APIs.
While porting it to WinRT I've decided to try to use WRL instead of C++/CX as much as possible. So right now I can create and consume most of the required WinRT objects. But I've faced absolute obstacle while working with Async objects, provided by WinRT.
For example, I use following code to enumerate HW devices:
// create interface to "static" members of DeviceInformation class
ComPtr<IDeviceInformationStatics> DeviceInformationStatics;
HRESULT hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Devices_Enumeration_DeviceInformation).Get(), &DeviceInformationStatics);
ComPtr<IAsyncOperation<DeviceInformationCollection*>> operation;
hr = DeviceInformationStatics->FindAllAsyncDeviceClass( DeviceClass_All, &operation);
At this point I have valid IAsyncOperation pointer. I thought it can be used like that:
task<ComPtr<DeviceInformationCollection*>> tsk(operation);
but I failed, because task<> constructor which accepts IAsyncOperation is declared under "#if defined(__cplusplus_winrt)" in ppltasks.h, which, in turn, depends on /ZW compiler option.
How I'm supposed to use IAsyncOperation object in this case? Actually, I only need to wait for operation to be completed.