simple_event seems to be unusable - Compilation error with wil::simple_event, const vs non-cost handler.
mikrause79 opened this issue · comments
Attempting to use wil::simple_event with C++/winrt generated code yields compilation errors.
The C++/winrt generated code is similar to:
*token = detach_fromwinrt::event_token(this->shim().MyEvent(reinterpret_cast<winrt::Windows::Foundation::EventHandler const>(&handler)));
This is supposed to call this function in event_base:
winrt::event_token operator()(T&& handler)
{
return m_handler.add(std::forward(handler));
}
But it can't cast the const handler from the C++/winrt generated code to the non-const in wil::details::event_base.
Note the original concept code from Raymond Chen's blog on this originally used const and can be used with C++/winrt.
I hit this as well. I think it's simply a typo.
sklar's initial implementation uses a const&
, not a &&
.
Fixed by #352