@@ -1130,15 +1130,14 @@ namespace cppwinrt
11301130 {
11311131 // we intentionally ignore errors when unregistering event handlers to be consistent with event_revoker
11321132 //
1133- // The `noexcept` versions will crash if check_hresult throws but that is no different than previous
1133+ // The `noexcept` versions will crash if .as<>() throws but that is no different than previous
11341134 // behavior where it would not check the cast result and nullptr crash. At least the exception will terminate
11351135 // immediately while preserving the error code and local variables.
11361136 format = R"( template <typename D%> auto consume_%<D%>::%(%) const noexcept
11371137 {%
11381138 if constexpr (!std::is_same_v<D, %>)
11391139 {
1140- auto const& [castedResult, code] = static_cast<D const*>(this)->template try_as_with_reason<%>();
1141- check_hresult(code);
1140+ auto const& castedResult = static_cast<D const*>(this)->template as<%>();
11421141 auto const abiType = *(abi_t<%>**)&castedResult;
11431142 abiType->%(%);
11441143 }
@@ -1156,8 +1155,7 @@ namespace cppwinrt
11561155 {%
11571156 if constexpr (!std::is_same_v<D, %>)
11581157 {
1159- auto const& [castedResult, code] = static_cast<D const*>(this)->template try_as_with_reason<%>();
1160- check_hresult(code);
1158+ auto const& castedResult = static_cast<D const*>(this)->template as<%>();
11611159 auto const abiType = *(abi_t<%>**)&castedResult;
11621160 WINRT_VERIFY_(0, abiType->%(%));
11631161 }
@@ -1176,8 +1174,7 @@ namespace cppwinrt
11761174 {%
11771175 if constexpr (!std::is_same_v<D, %>)
11781176 {
1179- auto const& [castedResult, code] = static_cast<D const*>(this)->template try_as_with_reason<%>();
1180- check_hresult(code);
1177+ auto const& castedResult = static_cast<D const*>(this)->template as<%>();
11811178 auto const abiType = *(abi_t<%>**)&castedResult;
11821179 check_hresult(abiType->%(%));
11831180 }
0 commit comments