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