- Problem: In
winrt::impl::promise_base::set_completed
, there is an unqualified call toinvoke()
that intended to resolve towinrt::impl::invoke
but instead resolves tostd::invoke
due to argument-dependent lookup. - Cause: In C++17, coroutines were an experimental feature and the first type in
Args1...
wasstd::experimental::coroutine_traits
. After promoting coroutines out of the experimental namespace in C++20,std
namespace was added to the argument-dependent lookup search, resulting instd::invoke
being found. - Solution for older version: To fix the issue in an older version of C++/WinRT without upgrading, one can put a better
invoke
in the searched-in namespaces. For example, declare a version ofinvoke
in thewinrt::Windows::Foundation
namespace that is considered better thanstd::invoke
(with a non-deduced finalstatus
parameter) before includingwinrt/Windows.Foundation.h
. If using WIL, includewil/cppwinrt.h
before any C++/WinRT header. Then implement theinvoke
by forwarding towinrt::impl::invoke
and assert that the C++/WinRT version is pre-bug-fix. - Author: Raymond Chen has been involved in Windows evolution for over 30 years. His Web site The Old New Thing grew popular and led to a book. He occasionally appears on the Windows Dev Docs Twitter account.
- Namespace details: Technically,
winrt::impl
andwil::details
namespaces are for internal use and not supposed to be relied on as they can change. But in this case, they are stable within the context of the fix as thestatic_assert
will fire once the header is upgraded, indicating the fix is no longer needed.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。