@@ -1135,21 +1135,37 @@ namespace cppwinrt
11351135 // immediately while preserving the error code and local variables.
11361136 format = R"( template <typename D%> auto consume_%<D%>::%(%) const noexcept
11371137 {%
1138- auto const& castedResult = static_cast<% const&>(static_cast<D const&>(*this));
1139- auto const abiType = *(abi_t<%>**)&castedResult;
1140- check_cast_result(abiType);
1141- abiType->%(%);%
1138+ if constexpr (!std::is_same_v<D, %>)
1139+ {
1140+ auto const& castedResult = static_cast<% const&>(static_cast<D const&>(*this));
1141+ auto const abiType = *(abi_t<%>**)&castedResult;
1142+ check_cast_result(abiType);
1143+ abiType->%(%);
1144+ }
1145+ else
1146+ {
1147+ auto const abiType = *(abi_t<%>**)this;
1148+ abiType->%(%);
1149+ }%
11421150 }
11431151)" ;
11441152 }
11451153 else
11461154 {
11471155 format = R"( template <typename D%> auto consume_%<D%>::%(%) const noexcept
11481156 {%
1149- auto const& castedResult = static_cast<% const&>(static_cast<D const&>(*this));
1150- auto const abiType = *(abi_t<%>**)&castedResult;
1151- check_cast_result(abiType);
1152- WINRT_VERIFY_(0, abiType->%(%));%
1157+ if constexpr (!std::is_same_v<D, %>)
1158+ {
1159+ auto const& castedResult = static_cast<% const&>(static_cast<D const&>(*this));
1160+ auto const abiType = *(abi_t<%>**)&castedResult;
1161+ check_cast_result(abiType);
1162+ WINRT_VERIFY_(0, abiType->%(%));
1163+ }
1164+ else
1165+ {
1166+ auto const abiType = *(abi_t<%>**)this;
1167+ WINRT_VERIFY_(0, abiType->%(%));
1168+ }%
11531169 }
11541170)" ;
11551171 }
@@ -1158,10 +1174,18 @@ namespace cppwinrt
11581174 {
11591175 format = R"( template <typename D%> auto consume_%<D%>::%(%) const
11601176 {%
1161- auto const& castedResult = static_cast<% const&>(static_cast<D const&>(*this));
1162- auto const abiType = *(abi_t<%>**)&castedResult;
1163- check_cast_result(abiType);
1164- check_hresult(abiType->%(%));%
1177+ if constexpr (!std::is_same_v<D, %>)
1178+ {
1179+ auto const& castedResult = static_cast<% const&>(static_cast<D const&>(*this));
1180+ auto const abiType = *(abi_t<%>**)&castedResult;
1181+ check_cast_result(abiType);
1182+ check_hresult(abiType->%(%));
1183+ }
1184+ else
1185+ {
1186+ auto const abiType = *(abi_t<%>**)this;
1187+ check_hresult(abiType->%(%));
1188+ }%
11651189 }
11661190)" ;
11671191 }
@@ -1175,6 +1199,10 @@ namespace cppwinrt
11751199 bind<write_consume_return_type>(signature, false ),
11761200 type,
11771201 type,
1202+ type,
1203+ get_abi_name (method),
1204+ bind<write_abi_args>(signature),
1205+ type,
11781206 get_abi_name (method),
11791207 bind<write_abi_args>(signature),
11801208 bind<write_consume_return_statement>(signature));
0 commit comments