Skip to content

Commit a7ee860

Browse files
authored
Remove WINRT_IMPL_AUTO workaround (#1117)
1 parent 8484e43 commit a7ee860

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

cppwinrt/code_writers.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -992,9 +992,8 @@ namespace cppwinrt
992992
auto method_name = get_name(method);
993993
auto type = method.Parent();
994994

995-
w.write(" %WINRT_IMPL_AUTO(%) %(%) const%;\n",
995+
w.write(" %auto %(%) const%;\n",
996996
is_get_overload(method) ? "[[nodiscard]] " : "",
997-
signature.return_signature(),
998997
method_name,
999998
bind<write_consume_params>(signature),
1000999
is_noexcept(method) ? " noexcept" : "");
@@ -1133,15 +1132,15 @@ namespace cppwinrt
11331132
if (is_remove_overload(method))
11341133
{
11351134
// we intentionally ignore errors when unregistering event handlers to be consistent with event_revoker
1136-
format = R"( template <typename D%> WINRT_IMPL_AUTO(%) consume_%<D%>::%(%) const noexcept
1135+
format = R"( template <typename D%> auto consume_%<D%>::%(%) const noexcept
11371136
{%
11381137
WINRT_IMPL_SHIM(%)->%(%);%
11391138
}
11401139
)";
11411140
}
11421141
else
11431142
{
1144-
format = R"( template <typename D%> WINRT_IMPL_AUTO(%) consume_%<D%>::%(%) const noexcept
1143+
format = R"( template <typename D%> auto consume_%<D%>::%(%) const noexcept
11451144
{%
11461145
WINRT_VERIFY_(0, WINRT_IMPL_SHIM(%)->%(%));%
11471146
}
@@ -1150,7 +1149,7 @@ namespace cppwinrt
11501149
}
11511150
else
11521151
{
1153-
format = R"( template <typename D%> WINRT_IMPL_AUTO(%) consume_%<D%>::%(%) const
1152+
format = R"( template <typename D%> auto consume_%<D%>::%(%) const
11541153
{%
11551154
check_hresult(WINRT_IMPL_SHIM(%)->%(%));%
11561155
}
@@ -1159,7 +1158,6 @@ namespace cppwinrt
11591158

11601159
w.write(format,
11611160
bind<write_comma_generic_typenames>(generics),
1162-
signature.return_signature(),
11631161
type_impl_name,
11641162
bind<write_comma_generic_types>(generics),
11651163
method_name,
@@ -1207,14 +1205,13 @@ namespace cppwinrt
12071205
// return static_cast<% const&>(*this).%(%);
12081206
//
12091207

1210-
std::string_view format = R"( inline WINRT_IMPL_AUTO(%) %::%(%) const%
1208+
std::string_view format = R"( inline auto %::%(%) const%
12111209
{
12121210
return [&](% const& winrt_impl_base) { return winrt_impl_base.%(%); }(*this);
12131211
}
12141212
)";
12151213

12161214
w.write(format,
1217-
signature.return_signature(),
12181215
class_type.TypeName(),
12191216
method_name,
12201217
bind<write_consume_params>(signature),
@@ -1999,7 +1996,7 @@ struct __declspec(empty_bases) produce_dispatch_to_overridable<T, D, %>
19991996

20001997
static void write_interface_override_method(writer& w, MethodDef const& method, std::string_view const& interface_name)
20011998
{
2002-
auto format = R"( template <typename D> WINRT_IMPL_AUTO(%) %T<D>::%(%) const%
1999+
auto format = R"( template <typename D> auto %T<D>::%(%) const%
20032000
{
20042001
return shim().template try_as<%>().%(%);
20052002
}
@@ -2009,7 +2006,6 @@ struct __declspec(empty_bases) produce_dispatch_to_overridable<T, D, %>
20092006
auto method_name = get_name(method);
20102007

20112008
w.write(format,
2012-
signature.return_signature(),
20132009
interface_name,
20142010
method_name,
20152011
bind<write_consume_params>(signature),

strings/base_macros.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@
1515

1616
#define WINRT_IMPL_SHIM(...) (*(abi_t<__VA_ARGS__>**)&static_cast<__VA_ARGS__ const&>(static_cast<D const&>(*this)))
1717

18-
#ifdef __INTELLISENSE__
19-
#define WINRT_IMPL_AUTO(...) __VA_ARGS__
20-
#else
21-
#define WINRT_IMPL_AUTO(...) auto
22-
#endif
23-
2418
// Note: this is a workaround for a false-positive warning produced by the Visual C++ 15.9 compiler.
2519
#pragma warning(disable : 5046)
2620

0 commit comments

Comments
 (0)