Simplify ErrCode::anyOf using binary left fold

This accepts arguments with implicit operator== available

Change-Id: Ibaf750471798948bf419e463252f67d470b485de
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109884
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski 2021-01-26 09:43:32 +01:00
parent ed6765d318
commit 92365b925c

View file

@ -141,14 +141,12 @@ public:
return "0x" + OUString::number(m_value, 16); return "0x" + OUString::number(m_value, 16);
} }
bool anyOf(ErrCode v) const { template <typename... Args> bool anyOf(Args... args) const
return *this == v; {
static_assert(sizeof...(args) > 0);
return (... || (*this == args));
} }
template<typename... Args>
bool anyOf(ErrCode first, Args... args) const {
return *this == first || anyOf(args...);
}
private: private:
sal_uInt32 m_value; sal_uInt32 m_value;
}; };