Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <type_traits>
- template <typename C, C beginVal, C endVal>
- class Iterator {
- typedef typename std::underlying_type<C>::type val_t;
- int val;
- public:
- Iterator(const C & f) : val(static_cast<val_t>(f)) {}
- Iterator() : val(static_cast<val_t>(beginVal)) {}
- Iterator operator++() {
- ++val;
- return *this;
- }
- C operator*() { return static_cast<C>(val); }
- Iterator begin() { return *this; } //default ctor is good
- Iterator end() {
- static const Iterator endIter = ++Iterator(endVal); // cache it
- return endIter;
- }
- bool operator!=(const Iterator& i) { return val != i.val; }
- };
- typedef Iterator<LtModeType, LtModeType_MIN, LtModeType_MAX> modeIterator;
Add Comment
Please, Sign In to add comment