diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-07-08 16:37:54 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-07-08 16:47:31 +0200 |
commit | e0fe01bb033b834e37b9340ea849557b346ee16e (patch) | |
tree | e8c3932697ca1b820a8bd0f3970a8a60b04719f2 /include/tools/link.hxx | |
parent | 4c28c8051ac99bd2a39ad06af35d87c2ddf2677e (diff) |
Prepare for loplugin:redundantcast checking for redundant static_casts
Change-Id: Id113c4e99e74c40b577841e3486aea295bbd0310
Diffstat (limited to 'include/tools/link.hxx')
-rw-r--r-- | include/tools/link.hxx | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/include/tools/link.hxx b/include/tools/link.hxx index c37dd1cfa25d..f46e84e7c578 100644 --- a/include/tools/link.hxx +++ b/include/tools/link.hxx @@ -68,7 +68,7 @@ SAL_UNUSED_PARAMETER Class *, SAL_UNUSED_PARAMETER ArgType) #define LINK(Instance, Class, Member) ::tools::detail::makeLink( \ - static_cast<Class *>(Instance), &Class::LinkStub##Member) + ::tools::detail::castTo<Class *>(Instance), &Class::LinkStub##Member) template<typename Arg, typename Ret> class SAL_WARN_UNUSED Link { @@ -113,6 +113,11 @@ class LinkParamNone { LinkParamNone() = delete; }; namespace tools { namespace detail { +// Avoids loplugin:redundantcast in LINK macro, in the common case that Instance +// is already of type Class * (instead of a derived type): +template<typename To, typename From> To castTo(From from) +{ return static_cast<To>(from); } + template<typename Arg, typename Ret> Link<Arg, Ret> makeLink(void * instance, Ret (* function)(void *, Arg)) { return Link<Arg, Ret>(instance, function); |