我正在尝试使用 C++/CX 创建 WinRT 组件。我有以下代码,但无法编译。它有什么问题?据我了解,PPL 任务应该透明地转换为 IAsyncOperation 如果它是一个有结果的任务。
IAsyncOperation<Boolean>^ Class::OpAsync()
{
return create_task([] () { return true; });
}
错误信息
error C2440: 'return' : cannot convert from 'Concurrency::task<_ReturnType>' to 'Windows::Foundation::IAsyncOperation<TResult> ^'
with
[
_ReturnType=bool
]
and
[
TResult=bool
]
No user-defined-conversion operator available, or
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called