This class simplifies the process of iterating over strongly typed enums. Example: typedef EnumIterator<enum, enum::firstVal, enum::lastVal> Iterator; for (enum x : Iterator()) { ... } Typically, the iterator will be defined in the include file that defines the enum. The endVal value should be first value that will NOT be processed in a loop. This means defining a final "Last" enumeration value in the enum that won't be iterated over. This is done to facilitate adding additional enumeration values without having to change the code that defines the iterator.
Definition at line 68 of file EnumIterator.hpp.
#include <EnumIterator.hpp>
Public Member Functions | |
EnumIterator | begin () |
EnumIterator | end () |
Iterator end value. More... | |
EnumIterator () | |
EnumIterator (const C &f) | |
Initialize the iterator to a specific value. More... | |
bool | operator!= (const EnumIterator &i) |
Comparison to assist in iteration. More... | |
C | operator* () |
Dereference the iterator by returning the current enum value. More... | |
EnumIterator & | operator++ () |
Private Types | |
typedef std::underlying_type< C >::type | ValType |
Value type as derived from the enum typename. More... | |
Private Attributes | |
ValType | val |
Current iterator value. More... | |
|
private |
Value type as derived from the enum typename.
Definition at line 71 of file EnumIterator.hpp.
|
inline |
Default iterator initializes to the beginVal specified in the template instantiation.
Definition at line 77 of file EnumIterator.hpp.
|
inline |
Initialize the iterator to a specific value.
Definition at line 81 of file EnumIterator.hpp.
|
inline |
Iterator start value, which can be the value initialized from the value constructor.
Definition at line 99 of file EnumIterator.hpp.
|
inline |
Iterator end value.
Definition at line 102 of file EnumIterator.hpp.
|
inline |
Comparison to assist in iteration.
Definition at line 108 of file EnumIterator.hpp.
|
inline |
Dereference the iterator by returning the current enum value.
Definition at line 95 of file EnumIterator.hpp.
|
inline |
Increment the iterator to the next enum
Definition at line 89 of file EnumIterator.hpp.
|
private |
Current iterator value.
Definition at line 73 of file EnumIterator.hpp.