8#ifndef HPP_ALIB_ENUMS_ARITHMETICAL
9#define HPP_ALIB_ENUMS_ARITHMETICAL 1
11#if !defined(HPP_ALIB) && !defined(ALIB_DOX)
17#if !defined (HPP_ALIB_LANG_TMP) && !defined(ALIB_DOX)
21namespace alib {
namespace enums {
69template<
typename TEnum,
typename TEnableIf>
72template<
typename TEnum,
73 typename TEnableIf=
ATMP_VOID_IF(std::is_enum<TEnum>::value)>
80template<
typename TEnum>
90#define ALIB_ENUMS_MAKE_ARITHMETICAL(TEnum) \
91namespace alib::enums { \
92template<> struct T_EnumIsArithmetical<TEnum> : public std::true_type {}; } \
102namespace alib {
namespace enums {
112namespace arithmetical {
127template<
typename TEnum>
134operator< (TEnum lhs,
typename std::underlying_type<TEnum>::type rhs)
noexcept(
true)
136 using TValue=
typename std::underlying_type<TEnum>::type;
137 return TValue(lhs) < rhs ;
152template<
typename TEnum>
159operator<= (TEnum lhs,
typename std::underlying_type<TEnum>::type rhs)
noexcept(
true)
161 using TValue=
typename std::underlying_type<TEnum>::type;
162 return TValue(lhs) <= rhs;
177template<
typename TEnum>
184operator> (TEnum lhs,
typename std::underlying_type<TEnum>::type rhs)
noexcept(
true)
186 using TValue=
typename std::underlying_type<TEnum>::type;
187 return TValue(lhs) > rhs;
204template<
typename TEnum>
211operator>= (TEnum lhs,
typename std::underlying_type<TEnum>::type rhs)
noexcept(
true)
213 using TValue=
typename std::underlying_type<TEnum>::type;
214 return TValue(lhs) >= rhs ;
229template<
typename TEnum>
238 using TValue=
typename std::underlying_type<TEnum>::type;
239 return TEnum( TValue(lhs) + TValue(rhs) );
253template<
typename TEnum>
260operator+ (TEnum lhs,
typename std::underlying_type<TEnum>::type rhs)
noexcept(
true)
262 using TValue=
typename std::underlying_type<TEnum>::type;
263 return TEnum( TValue(lhs) + rhs );
278template<
typename TEnum>
287 using TValue=
typename std::underlying_type<TEnum>::type;
288 return lhs= TEnum( TValue(lhs) + TValue(rhs) );
302template<
typename TEnum>
309operator+= (TEnum& lhs,
typename std::underlying_type<TEnum>::type rhs)
noexcept(
true)
311 using TValue=
typename std::underlying_type<TEnum>::type;
312 return lhs= TEnum( TValue(lhs) + rhs );
325template<
typename TEnum>
334 using TValue=
typename std::underlying_type<TEnum>::type;
335 return arg= TEnum( TValue(arg) + 1 );
348template<
typename TEnum>
357 using TValue=
typename std::underlying_type<TEnum>::type;
359 arg= TEnum( TValue(arg) + 1 );
374template<
typename TEnum>
383 using TValue=
typename std::underlying_type<TEnum>::type;
384 return TEnum( TValue(lhs) - TValue(rhs) );
399template<
typename TEnum>
406operator- (TEnum lhs,
typename std::underlying_type<TEnum>::type rhs)
noexcept(
true)
408 using TValue=
typename std::underlying_type<TEnum>::type;
409 return TEnum( TValue(lhs) - rhs );
423template<
typename TEnum>
432 using TValue=
typename std::underlying_type<TEnum>::type;
433 return lhs= TEnum( TValue(lhs) - TValue(rhs) );
447template<
typename TEnum>
454operator-= (TEnum& lhs,
typename std::underlying_type<TEnum>::type rhs)
noexcept(
true)
456 using TValue=
typename std::underlying_type<TEnum>::type;
457 return lhs= TEnum( TValue(lhs) - rhs );
470template<
typename TEnum>
479 using TValue=
typename std::underlying_type<TEnum>::type;
480 return arg= TEnum( TValue(arg) - 1 );
494template<
typename TEnum>
503 using TValue=
typename std::underlying_type<TEnum>::type;
505 arg= TEnum( TValue(arg) - 1 );
519template<
typename TEnum>
541template<
typename TEnum>
550 using TValue=
typename std::underlying_type<TEnum>::type;
551 return TEnum( - TValue(arg) );
566template<
typename TEnum>
573operator* (TEnum lhs,
typename std::underlying_type<TEnum>::type rhs)
noexcept(
true)
575 using TValue=
typename std::underlying_type<TEnum>::type;
576 return TEnum( TValue(lhs) * rhs );
591template<
typename TEnum>
598operator*= (TEnum& lhs,
typename std::underlying_type<TEnum>::type rhs)
noexcept(
true)
600 using TValue=
typename std::underlying_type<TEnum>::type;
601 return lhs= TEnum( TValue(lhs) * rhs );
615template<
typename TEnum>
622operator/ (TEnum lhs,
typename std::underlying_type<TEnum>::type rhs)
noexcept(
true)
624 using TValue=
typename std::underlying_type<TEnum>::type;
625 return TEnum( TValue(lhs) / rhs );
640template<
typename TEnum>
647operator/= (TEnum& lhs,
typename std::underlying_type<TEnum>::type rhs)
noexcept(
true)
649 using TValue=
typename std::underlying_type<TEnum>::type;
650 return lhs= TEnum( TValue(lhs) / rhs );
665template<
typename TEnum>
672operator% (TEnum lhs,
typename std::underlying_type<TEnum>::type rhs)
noexcept(
true)
674 using TValue=
typename std::underlying_type<TEnum>::type;
675 return TEnum( TValue(lhs) % rhs );
690template<
typename TEnum>
697operator%= (TEnum& lhs,
typename std::underlying_type<TEnum>::type rhs)
noexcept(
true)
699 using TValue=
typename std::underlying_type<TEnum>::type;
700 return lhs= TEnum( TValue(lhs) % rhs );
715template<
typename TEnum>
722operator<< (TEnum lhs,
typename std::underlying_type<TEnum>::type rhs)
noexcept(
true)
724 using TValue=
typename std::underlying_type<TEnum>::type;
725 return TEnum( TValue(lhs) << rhs );
739template<
typename TEnum>
746operator<<= (TEnum& lhs,
typename std::underlying_type<TEnum>::type rhs)
noexcept(
true)
748 using TValue=
typename std::underlying_type<TEnum>::type;
749 return lhs= TEnum( TValue(lhs) << rhs );
764template<
typename TEnum>
771operator>> (TEnum lhs,
typename std::underlying_type<TEnum>::type rhs)
noexcept(
true)
773 using TValue=
typename std::underlying_type<TEnum>::type;
774 return TEnum( TValue(lhs) << rhs );
788template<
typename TEnum>
795operator>>= (TEnum& lhs,
typename std::underlying_type<TEnum>::type rhs)
noexcept(
true)
797 using TValue=
typename std::underlying_type<TEnum>::type;
798 return lhs= TEnum( TValue(lhs) >> rhs );
#define ALIB_ASSERT_MODULE(modulename)
#define ATMP_VOID_IF(Cond)
#define ATMP_T_IF(T, Cond)
constexpr bool operator<=(TEnum lhs, typename std::underlying_type< TEnum >::type rhs) noexcept(true)
constexpr TEnum operator<<=(TEnum &lhs, typename std::underlying_type< TEnum >::type rhs) noexcept(true)
constexpr TEnum operator-=(TEnum &lhs, TEnum rhs) noexcept(true)
constexpr bool operator>(TEnum lhs, typename std::underlying_type< TEnum >::type rhs) noexcept(true)
constexpr TEnum operator*(TEnum lhs, typename std::underlying_type< TEnum >::type rhs) noexcept(true)
constexpr TEnum operator<<(TEnum lhs, typename std::underlying_type< TEnum >::type rhs) noexcept(true)
constexpr TEnum operator/(TEnum lhs, typename std::underlying_type< TEnum >::type rhs) noexcept(true)
constexpr TEnum operator*=(TEnum &lhs, typename std::underlying_type< TEnum >::type rhs) noexcept(true)
constexpr TEnum operator>>=(TEnum &lhs, typename std::underlying_type< TEnum >::type rhs) noexcept(true)
constexpr bool operator<(TEnum lhs, typename std::underlying_type< TEnum >::type rhs) noexcept(true)
constexpr TEnum operator++(TEnum &arg) noexcept(true)
constexpr TEnum operator--(TEnum &arg) noexcept(true)
constexpr TEnum operator%=(TEnum &lhs, typename std::underlying_type< TEnum >::type rhs) noexcept(true)
constexpr TEnum operator/=(TEnum &lhs, typename std::underlying_type< TEnum >::type rhs) noexcept(true)
constexpr TEnum operator+(TEnum lhs, TEnum rhs) noexcept(true)
constexpr TEnum operator>>(TEnum lhs, typename std::underlying_type< TEnum >::type rhs) noexcept(true)
constexpr bool operator>=(TEnum lhs, typename std::underlying_type< TEnum >::type rhs) noexcept(true)
constexpr TEnum operator-(TEnum lhs, TEnum rhs) noexcept(true)
constexpr TEnum operator%(TEnum lhs, typename std::underlying_type< TEnum >::type rhs) noexcept(true)
constexpr TEnum operator+=(TEnum &lhs, TEnum rhs) noexcept(true)