Core/Flags: Add Test method
This commit is contained in:
@@ -48,6 +48,8 @@ namespace Nz
|
||||
constexpr Flags(BitField value = 0);
|
||||
constexpr Flags(E enumVal);
|
||||
|
||||
constexpr bool Test(const Flags& flags) const;
|
||||
|
||||
explicit constexpr operator bool() const;
|
||||
template<typename T, typename = std::enable_if_t<std::is_integral<T>::value && sizeof(T) >= sizeof(BitField)>> explicit constexpr operator T() const;
|
||||
|
||||
|
||||
@@ -40,7 +40,17 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Tests a Flags
|
||||
* \brief Tests if all flags from a Flags object are enabled
|
||||
* \return True if all tested flags are enabled.
|
||||
*/
|
||||
template<typename E>
|
||||
constexpr bool Flags<E>::Test(const Flags& flags) const
|
||||
{
|
||||
return (m_value & flags.m_value) == flags.m_value;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Tests any flag
|
||||
* \return True if any flag is enabled.
|
||||
*
|
||||
* This will convert to a boolean value allowing to check if any flag is set.
|
||||
|
||||
Reference in New Issue
Block a user