Skip to content

Commit 5858e0a

Browse files
committed
Workaround compiler issue by hoisting access token guard outside of the function
1 parent a0d17b6 commit 5858e0a

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

strings/base_security.h

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -69,31 +69,32 @@ WINRT_EXPORT namespace winrt
6969
check_bool(WINRT_IMPL_SetThreadToken(nullptr, get()));
7070
}
7171

72-
/*TODO: figure out why compiler ICEs auto operator()() const
73-
{
74-
struct guard
75-
{
76-
guard(access_token&& previous) noexcept : m_previous(std::move(previous))
77-
{
78-
}
79-
80-
~guard()
81-
{
82-
m_previous.revert();
83-
}
84-
85-
guard(guard const&)
86-
{
87-
// A Visual C++ compiler bug (550631) requires the copy constructor even though it is never called.
88-
WINRT_ASSERT(false);
89-
}
72+
auto operator()() const;
73+
};
74+
}
9075

91-
private:
76+
namespace winrt::impl
77+
{
78+
struct access_token_guard
79+
{
80+
access_token_guard(access_token&& previous) noexcept : m_previous(std::move(previous))
81+
{
82+
}
9283

93-
access_token const m_previous;
94-
};
84+
~access_token_guard()
85+
{
86+
m_previous.revert();
87+
}
9588

96-
return guard(impersonate());
97-
}*/
89+
private:
90+
access_token const m_previous;
9891
};
9992
}
93+
94+
WINRT_EXPORT namespace winrt
95+
{
96+
auto access_token::operator()() const
97+
{
98+
return impl::access_token_guard(impersonate());
99+
}
100+
}

0 commit comments

Comments
 (0)