diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2016-08-29 23:56:22 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2016-08-29 23:56:22 +0100 |
| commit | cbe38b2f962443f5fefcbbb5f7552f50c0e841fc (patch) | |
| tree | 85a82f0afb84a5cc217bcefd336c5c81989a55ee /src/flags.hh | |
| parent | 95c21a4ebd60c8f52f0b6dea2bb82f9ae6b0014d (diff) | |
Use flags and bit operations instead of bools in RankedMatch
full match is now the most important flag for comparison.
Diffstat (limited to 'src/flags.hh')
| -rw-r--r-- | src/flags.hh | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/flags.hh b/src/flags.hh index 6b72ba05..824d37ca 100644 --- a/src/flags.hh +++ b/src/flags.hh @@ -37,6 +37,9 @@ struct TestableFlags Flags value; constexpr operator bool() const { return (UnderlyingType<Flags>)value; } constexpr operator Flags() const { return value; } + + bool operator==(const TestableFlags<Flags>& other) const { return value == other.value; } + bool operator!=(const TestableFlags<Flags>& other) const { return value != other.value; } }; template<typename Flags, typename = EnableIfWithBitOps<Flags>> @@ -58,6 +61,19 @@ constexpr Flags operator~(Flags lhs) return (Flags)(~(UnderlyingType<Flags>)lhs); } +template<typename Flags, typename = EnableIfWithBitOps<Flags>> +constexpr Flags operator^(Flags lhs, Flags rhs) +{ + return (Flags)((UnderlyingType<Flags>) lhs ^ (UnderlyingType<Flags>) rhs); +} + +template<typename Flags, typename = EnableIfWithBitOps<Flags>> +Flags& operator^=(Flags& lhs, Flags rhs) +{ + (UnderlyingType<Flags>&) lhs ^= (UnderlyingType<Flags>) rhs; + return lhs; +} + } #endif // flags_hh_INCLUDED |
