File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed
Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -266,8 +266,6 @@ namespace winrt::impl
266266 template <typename T, typename From>
267267 T unbox_value_type (From&& value)
268268 {
269- static_assert (!is_com_interface_v<T>);
270-
271269 if (!value)
272270 {
273271 throw hresult_no_interface ();
Original file line number Diff line number Diff line change 1+ #include " pch.h"
2+
3+ TEST_CASE (" box_delegate" )
4+ {
5+ using Handler = winrt::Windows::Foundation::TypedEventHandler<int , bool >;
6+
7+ Handler d = [](auto &&...) {};
8+ REQUIRE (d);
9+
10+ auto box = winrt::box_value (d);
11+
12+ Handler unbox = winrt::unbox_value<Handler>(box);
13+ REQUIRE (winrt::get_abi (unbox) == winrt::get_abi (d));
14+
15+ unbox = winrt::unbox_value_or<Handler>(box, Handler {});
16+ REQUIRE (winrt::get_abi (unbox) == winrt::get_abi (d));
17+
18+ unbox = winrt::unbox_value_or<Handler>(winrt::Windows::Foundation::IInspectable{}, Handler{});
19+ REQUIRE (!unbox);
20+ }
Original file line number Diff line number Diff line change 296296 <ClCompile Include =" async_completed.cpp" />
297297 <ClCompile Include =" async_propagate_cancel.cpp" />
298298 <ClCompile Include =" async_ref_result.cpp" />
299+ <ClCompile Include =" box_delegate.cpp" />
299300 <ClCompile Include =" box_guid.cpp" />
300301 <ClCompile Include =" capture.cpp" />
301302 <ClCompile Include =" coro_foundation.cpp" >
You can’t perform that action at this time.
0 commit comments