8#ifndef HPP_ALIB_ENUMS_BITWISE
9#define HPP_ALIB_ENUMS_BITWISE 1
11#if !defined(HPP_ALIB) && !defined(ALIB_DOX)
17#if !defined(HPP_ALIB_ENUMS_ARITHMETICAL)
21#if !defined (HPP_ALIB_ENUMS_UNDERLYING_INTEGRAL)
25#if !defined(HPP_ALIB_LANG_BITS)
100template<
typename TEnum,
typename TEnableIf>
103template<
typename TEnum,
104 typename TEnableIf=
typename std::enable_if<std::is_enum<TEnum>::value>::type>
111template<
typename TEnum>
120#define ALIB_ENUMS_MAKE_BITWISE(TEnum) \
121namespace alib::enums { \
123struct T_EnumIsBitwise<TEnum> : public std::true_type {}; }
134namespace alib {
namespace enums {
164template<
typename TEnum>
169typename std::enable_if<alib::enums::T_EnumIsBitwise<TEnum>::value, TEnum>::type
173 using TBits=
typename std::underlying_type<TEnum>::type;
174 return TEnum(TBits(lhs) & TBits(rhs));
188template<
typename TEnum>
193typename std::enable_if<alib::enums::T_EnumIsBitwise<TEnum>::value, TEnum>::type
197 using TBits=
typename std::underlying_type<TEnum>::type;
198 return lhs= TEnum( TBits(lhs) & TBits(rhs) );
212template<
typename TEnum>
217typename std::enable_if<alib::enums::T_EnumIsBitwise<TEnum>::value, TEnum>::type
221 using TBits=
typename std::underlying_type<TEnum>::type;
222 return TEnum(TBits(lhs) | TBits(rhs));
236template<
typename TEnum>
241typename std::enable_if<alib::enums::T_EnumIsBitwise<TEnum>::value, TEnum>::type
245 using TBits=
typename std::underlying_type<TEnum>::type;
246 return lhs= TEnum( TBits(lhs) | TBits(rhs) );
260template<
typename TEnum>
265typename std::enable_if<alib::enums::T_EnumIsBitwise<TEnum>::value, TEnum>::type
269 using TBits=
typename std::underlying_type<TEnum>::type;
270 return TEnum(TBits(lhs) ^ TBits(rhs));
284template<
typename TEnum>
289typename std::enable_if<alib::enums::T_EnumIsBitwise<TEnum>::value, TEnum>::type
293 using TBits=
typename std::underlying_type<TEnum>::type;
294 return lhs= TEnum( TBits(lhs) ^ TBits(rhs) );
311template<
typename TEnum>
316typename std::enable_if<alib::enums::T_EnumIsBitwise<TEnum>::value, TEnum>::type
320 using TBits=
typename std::underlying_type<TEnum>::type;
321 return TEnum( ~ TBits(op) );
338template<
typename TEnum>
343typename std::enable_if< alib::enums::T_EnumIsBitwise <TEnum>::value
348 using TBits=
typename std::underlying_type<TEnum>::type;
349 return TEnum(TBits(lhs) | TBits(rhs));
365template<
typename TEnum>
370typename std::enable_if< alib::enums::T_EnumIsBitwise <TEnum>::value
375 using TBits=
typename std::underlying_type<TEnum>::type;
376 return lhs= TEnum( TBits(lhs) | TBits(rhs) );
394template<
typename TEnum>
399typename std::enable_if< alib::enums::T_EnumIsBitwise <TEnum>::value
404 using TBits=
typename std::underlying_type<TEnum>::type;
405 return TEnum( TBits(lhs) & (~TBits(rhs)) );
423template<
typename TEnum>
428typename std::enable_if< alib::enums::T_EnumIsBitwise <TEnum>::value
433 using TBits=
typename std::underlying_type<TEnum>::type;
434 return lhs= TEnum( TBits(lhs) & (~TBits(rhs)) );
437#if !defined(ALIB_DOX)
457template<
typename TEnum>
459bool HasBits(TEnum element, TEnum selection)
noexcept;
461template<
typename TEnum>
464HasBits(TEnum element, TEnum selection)
noexcept
466 using TBits=
typename std::underlying_type<TEnum>::type;
467 return ( TBits(element) & TBits(selection) ) == TBits(selection);
482template<
typename TEnum>
486template<
typename TEnum>
#define ALIB_ASSERT_MODULE(modulename)
#define ATMP_T_IF(T, Cond)
constexpr TEnum operator&(TEnum lhs, TEnum rhs) noexcept(true)
constexpr TEnum operator-=(TEnum &lhs, TEnum rhs) noexcept(true)
constexpr TEnum operator|(TEnum lhs, TEnum rhs) noexcept(true)
constexpr bool HasBits(TEnum element, TEnum selection) noexcept
constexpr TEnum operator&=(TEnum &lhs, TEnum rhs) noexcept(true)
constexpr TEnum operator^(TEnum lhs, TEnum rhs) noexcept(true)
constexpr TEnum operator^=(TEnum &lhs, TEnum rhs) noexcept(true)
constexpr TEnum operator+(TEnum lhs, TEnum rhs) noexcept(true)
constexpr TEnum operator-(TEnum lhs, TEnum rhs) noexcept(true)
static constexpr int CountElements(TEnum value)
constexpr bool operator|=(TEnum &lhs, TEnum rhs) noexcept(true)
constexpr TEnum operator+=(TEnum &lhs, TEnum rhs) noexcept(true)
constexpr TEnum operator~(TEnum op) noexcept(true)
constexpr std::underlying_type< TEnum >::type UnderlyingIntegral(TEnum element) noexcept(true)
constexpr int BitCount(TIntegral value)