9 #include <ka/typetraits.hpp>
10 #include <ka/macroregular.hpp>
11 #include <boost/range/adaptor/transformed.hpp>
12 #include <boost/range/numeric.hpp>
21 template <typename E, typename = ka::EnableIf<std::is_enum<E>::value>>
24 return static_cast<ka::UnderlyingType<E>
>(e);
59 template <
typename Type>
77 KA_GENERATE_FRIEND_REGULAR_OPS_1(
Flags, _value)
86 explicit Flags(std::initializer_list<Type> values)
87 : _value(boost::accumulate(values | boost::adaptors::transformed([](const Type& t) {
return underlying(t); }),
89 std::bit_or<underlying_type>()))
96 bool test(
const Type& t)
const
115 return Flags{a._value & b._value};
120 return Flags{a._value | b._value};
125 return Flags{a._value ^ b._value};
130 return Flags{~a._value};
135 a._value |= b._value;
141 a._value &= b._value;
147 a._value ^= b._value;
156 #endif // QI_FLAGS_HPP
Flags & set(const Type &t)
friend const underlying_type & underlying(const Flags &f)
friend Flags operator~(const Flags &a)
friend Flags & operator^=(Flags &a, const Flags &b)
friend Flags operator^(const Flags &a, const Flags &b)
friend Flags operator&(const Flags &a, const Flags &b)
Flags(std::initializer_list< Type > values)
Flags & reset(const Type &t)
ka::Decay< decltype(underlying(std::declval< Option >()))> underlying_type
friend Flags & operator|=(Flags &a, const Flags &b)
friend Flags & operator&=(Flags &a, const Flags &b)
bool test(const Type &t) const
auto underlying(const E &e) -> ka::UnderlyingType< E >
friend Flags operator|(const Flags &a, const Flags &b)