Skip to content

Commit 08f23ea

Browse files
committed
Remove check_cast_result in favor of check_hresult now that they are the same code
1 parent 00cdba2 commit 08f23ea

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

cppwinrt/code_writers.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,15 +1130,15 @@ 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_cast_result throws but that is no different than previous
1133+
// The `noexcept` versions will crash if check_hresult 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
{
11401140
auto const [castedResult, code] = static_cast<D const*>(this)->template try_as_with_reason<%>();
1141-
check_cast_result(code);
1141+
check_hresult(code);
11421142
auto const abiType = *(abi_t<%>**)&castedResult;
11431143
abiType->%(%);
11441144
}
@@ -1157,7 +1157,7 @@ namespace cppwinrt
11571157
if constexpr (!std::is_same_v<D, %>)
11581158
{
11591159
auto const [castedResult, code] = static_cast<D const*>(this)->template try_as_with_reason<%>();
1160-
check_cast_result(code);
1160+
check_hresult(code);
11611161
auto const abiType = *(abi_t<%>**)&castedResult;
11621162
WINRT_VERIFY_(0, abiType->%(%));
11631163
}
@@ -1177,7 +1177,7 @@ namespace cppwinrt
11771177
if constexpr (!std::is_same_v<D, %>)
11781178
{
11791179
auto const [castedResult, code] = static_cast<D const*>(this)->template try_as_with_reason<%>();
1180-
check_cast_result(code);
1180+
check_hresult(code);
11811181
auto const abiType = *(abi_t<%>**)&castedResult;
11821182
check_hresult(abiType->%(%));
11831183
}

strings/base_error.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -538,14 +538,6 @@ namespace winrt::impl
538538
}
539539
return result;
540540
}
541-
542-
inline WINRT_IMPL_NOINLINE void check_cast_result(hresult const result, winrt::impl::slim_source_location const& sourceInformation = winrt::impl::slim_source_location::current())
543-
{
544-
if (result != 0)
545-
{
546-
throw hresult_error(result, take_ownership_from_abi, sourceInformation);
547-
}
548-
}
549541
}
550542

551543
#undef WINRT_IMPL_RETURNADDRESS

0 commit comments

Comments
 (0)