8#ifndef HPP_ALIB_ENUMS_ITERABLE
9#define HPP_ALIB_ENUMS_ITERABLE 1
15#include "alib/enums/underlyingintegral.hpp"
19namespace alib {
namespace enums {
64template<
typename TEnum,
65 typename TEnableIf=
typename std::enable_if<std::is_enum<TEnum>::value>::type>
81 static constexpr TEnum
End;
92#define ALIB_ENUMS_MAKE_ITERABLE_BEGIN_END(TEnum, StartElement, StopElement ) \
93namespace alib::enums { \
94template<> struct T_EnumIsIterable<TEnum> : std::true_type \
96 static constexpr TEnum Begin = StartElement; \
97 static constexpr TEnum End = StopElement; \
100#define ALIB_ENUMS_MAKE_ITERABLE(TEnum, StopElement ) \
101ALIB_ENUMS_MAKE_ITERABLE_BEGIN_END( TEnum, TEnum(0), StopElement )
111namespace alib {
namespace enums {
132template<
typename TEnum,
typename TRhs=
int>
136template<
typename TEnum,
typename TRhs=
int>
140operator+ (TEnum element, TRhs summand)
noexcept
142 return TEnum( alib::UnderlyingIntegral(element)
143 +
static_cast<typename std::underlying_type<TEnum>::type
>(summand) );
158template<
typename TEnum,
typename TRhs=
int>
160TEnum
operator- (TEnum element, TRhs subtrahend)
noexcept;
163template<
typename TEnum,
typename TRhs=
int>
167operator- (TEnum element,
typename std::underlying_type<TEnum>::type subtrahend)
noexcept
169 return TEnum( alib::UnderlyingIntegral(element)
170 -
static_cast<typename std::underlying_type<TEnum>::type
>(subtrahend) );
179 namespace alib {
namespace enums {
199template<
typename TEnum,
typename TEnableIf>
202template<typename TEnum, typename TEnableIf
220 template<
typename TPo
inter,
typename TReference>
234 using TIntegral=
typename std::underlying_type<TEnum>::type;
284 return !(*
this == other);
461template<
typename TEnum,
typename TEnableIf=
void>
466template<
typename TEnum,
typename TEnableIf
TEnum p
The actual enum element.
bool operator<=(TRandomAccessIterator other) const
TEnum operator[](std::ptrdiff_t n) const
std::ptrdiff_t operator-(TRandomAccessIterator other) const
constexpr TRandomAccessIterator(TEnum _p=TEnum(0))
TRandomAccessIterator operator-(TIntegral n) const
bool operator<(TRandomAccessIterator other) const
typename std::underlying_type< TEnum >::type TIntegral
The underlying integer type.
bool operator>=(TRandomAccessIterator other) const
TRandomAccessIterator operator--(typename std::underlying_type< TEnum >::type)
TEnum value_type
Implementation of std::iterator_traits.
TRandomAccessIterator operator+(TIntegral n) const
TRandomAccessIterator & operator++()
TRandomAccessIterator & operator-=(TIntegral n)
std::random_access_iterator_tag iterator_category
Implementation of std::iterator_traits.
constexpr bool operator==(TRandomAccessIterator other) const
TRandomAccessIterator & operator+=(TIntegral n)
bool operator>(TRandomAccessIterator other) const
TPointer pointer
Implementation of std::iterator_traits.
TRandomAccessIterator & operator--()
constexpr bool operator!=(TRandomAccessIterator other) const
std::ptrdiff_t difference_type
Implementation of std::iterator_traits.
TReference reference
Implementation of std::iterator_traits.
constexpr TEnum operator*() const
TRandomAccessIterator operator++(typename std::underlying_type< TEnum >::type)
#define ALIB_ASSERT_MODULE(modulename)
#define ATMP_VOID_IF(Cond)
#define ATMP_EQ( T, TEqual)
#define ATMP_T_IF(T, Cond)
constexpr TEnum operator-(TEnum element, TRhs subtrahend) noexcept
constexpr TEnum operator+(TEnum element, TRhs summand) noexcept
constexpr std::underlying_type< TEnum >::type UnderlyingIntegral(TEnum element) noexcept
constexpr int MSB(TIntegral value)
ConstIterator end() const
TRandomAccessIterator< const TEnum *, const TEnum & > ConstIterator
The constant iterator exposed by this class. A Mutable version is not available.
ConstIterator begin() const
EnumIterator()=default
Default constructor.
static constexpr TEnum Begin
static constexpr TEnum End