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