#ifndef flags_hh_INCLUDED #define flags_hh_INCLUDED #include namespace Kakoune { template struct WithBitOps : std::false_type {}; template using UnderlyingType = typename std::underlying_type::type; template using EnableIfWithBitOps = typename std::enable_if::value>::type; template> constexpr Flags operator|(Flags lhs, Flags rhs) { return (Flags)((UnderlyingType) lhs | (UnderlyingType) rhs); } template> Flags& operator|=(Flags& lhs, Flags rhs) { (UnderlyingType&) lhs |= (UnderlyingType) rhs; return lhs; } template struct TestableFlags { Flags value; constexpr operator bool() const { return (UnderlyingType)value; } constexpr operator Flags() const { return value; } }; template> constexpr TestableFlags operator&(Flags lhs, Flags rhs) { return { (Flags)((UnderlyingType) lhs & (UnderlyingType) rhs) }; } template> Flags& operator&=(Flags& lhs, Flags rhs) { (UnderlyingType&) lhs &= (UnderlyingType) rhs; return lhs; } template> constexpr Flags operator~(Flags lhs) { return (Flags)(~(UnderlyingType)lhs); } } #endif // flags_hh_INCLUDED