 |
ALib C++ Library
|
Library Version: 1912 R0
Documentation generated by
|
Go to the documentation of this file.
8 #ifndef HPP_ALIB_ENUMS_ITERATABLE
9 #define HPP_ALIB_ENUMS_ITERATABLE 1
11 #if !defined (HPP_ALIB_ENUMS_BITWISE)
17 #if !defined (HPP_ALIB_ENUMS_UNDERLYING_INTEGRAL)
21 #if defined(_WIN32) && !defined (__INTRIN_H_)
25 #if !defined (_GLIBCXX_CSTDINT) && !defined (_CSTDINT_)
29 #if !defined (_GLIBCXX_ITERATOR) && !defined (_ITERATOR_)
33 namespace aworx {
namespace lib {
namespace enums {
78 template<
typename TEnum,
79 typename TEnableIf=
typename std::enable_if<std::is_enum<TEnum>::value>::type>
99 static constexpr TEnum
End;
110 #define ALIB_ENUMS_MAKE_ITERATABLE_BEGIN_END(TEnum, StartElement, StopElement ) \
111 namespace aworx { namespace lib { namespace enums { \
112 template<> struct T_EnumIsIteratable<TEnum> \
114 static constexpr TEnum Begin = StartElement; \
115 static constexpr TEnum End = StopElement; \
118 #define ALIB_ENUMS_MAKE_ITERATABLE(TEnum, StopElement ) \
119 ALIB_ENUMS_MAKE_ITERATABLE_BEGIN_END( TEnum, TEnum(0), StopElement )
128 #if defined(ALIB_DOX)
129 namespace aworx {
namespace lib {
namespace enums {
138 namespace iteratable {
141 #if defined(ALIB_DOX)
153 template<
typename TEnum>
155 TEnum
operator+ (TEnum element,
int addend) noexcept(
true);
157 template<
typename TEnum>
160 operator+ (TEnum element,
int addend) noexcept(
true)
166 #if defined(ALIB_DOX)
178 template<
typename TEnum>
180 TEnum
operator- (TEnum element,
int subtrahend) noexcept(
true);
183 template<
typename TEnum>
186 operator- (TEnum element,
int subtrahend) noexcept(
true)
194 #if defined(ALIB_DOX)
197 namespace aworx {
namespace lib {
namespace enums {
205 #if !defined(ALIB_DOX)
209 inline int getHighestBit(uint64_t value)
212 #if defined(__GNUC__) || defined(_WIN64)
214 #if defined(__GNUC__)
215 digits= 64 - __builtin_clzll( value );
218 _BitScanReverse64( &Index, value );
224 digits = value < ( static_cast<uint64_t>(1) << 8) ? 8
225 : value < ( static_cast<uint64_t>(1) << 16) ? 16
226 : value < ( static_cast<uint64_t>(1) << 32) ? 32
227 : value < ( static_cast<uint64_t>(1) << 48) ? 48 : 64;
230 uint64_t actSize= static_cast<uint64_t>(1) << (digits - 1);
231 while( value < actSize )
242 #endif // !defined(ALIB_DOX)
244 #if defined(ALIB_DOX)
257 template<
typename TEnum,
typename TEnableIf>
260 template<typename TEnum, typename TEnableIf
278 template<
typename TPo
inter,
typename TReference>
280 :
public std::iterator< std::random_access_iterator_tag,
292 using TIntegral=
typename std::underlying_type<TEnum>::type;
342 return !(*
this == other);
434 return static_cast<std::ptrdiff_t>(getHighestBit(static_cast<uint64_t>(
UnderlyingIntegral( p ) )))
435 - static_cast<std::ptrdiff_t>(getHighestBit(static_cast<uint64_t>(
UnderlyingIntegral( other.
p ) )));
445 return ( p + static_cast<TIntegral>( n ) );
520 #if defined(ALIB_DOX)
522 template<
typename TEnum,
typename TEnableIf=
void>
525 template<
typename TEnum,
typename TEnableIf
532 #endif // HPP_ALIB_ENUMS_ITERATABLE
constexpr std::underlying_type< TEnum >::type UnderlyingIntegral(TEnum element) noexcept(true)
typename std::underlying_type< TEnum >::type TIntegral
#define ALIB_ASSERT_MODULE(modulename)
constexpr bool operator==(TRandomAccessIterator other) const
TRandomAccessIterator operator-(TIntegral n) const
#define ATMP_VOID_IF(Cond)
ConstIterator end() const
#define ATMP_T_IF(T, Cond)
TEnum operator[](std::ptrdiff_t n) const
std::ptrdiff_t operator-(TRandomAccessIterator other) const
static constexpr TEnum Begin
constexpr TRandomAccessIterator(TEnum _p=TEnum(0))
bool operator>=(TRandomAccessIterator other) const
TRandomAccessIterator operator--(int)
TRandomAccessIterator operator+(TIntegral n) const
static constexpr TEnum End
constexpr TEnum operator*() const
#define ATMP_EQ( T, TEqual)
bool operator>(TRandomAccessIterator other) const
bool operator<=(TRandomAccessIterator other) const
bool operator<(TRandomAccessIterator other) const
TRandomAccessIterator & operator++()
TRandomAccessIterator operator++(int)
constexpr TEnum operator-(TEnum element, int subtrahend) noexcept(true)
constexpr bool operator!=(TRandomAccessIterator other) const
TRandomAccessIterator & operator--()
TRandomAccessIterator & operator+=(TIntegral n)
constexpr TEnum operator+(TEnum element, int addend) noexcept(true)
lib::enums::EnumIterator< TEnum, TEnableIf > EnumIterator
Type alias in namespace aworx.
TRandomAccessIterator & operator-=(TIntegral n)
ConstIterator begin() const