Guest User

Untitled

a guest
Apr 25th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <type_traits>
  2.  
  3. template <typename C, C beginVal, C endVal>
  4.  
  5. class Iterator {
  6. typedef typename std::underlying_type<C>::type val_t;
  7. int val;
  8. public:
  9. Iterator(const C & f) : val(static_cast<val_t>(f)) {}
  10. Iterator() : val(static_cast<val_t>(beginVal)) {}
  11. Iterator operator++() {
  12. ++val;
  13. return *this;
  14. }
  15. C operator*() { return static_cast<C>(val); }
  16. Iterator begin() { return *this; } //default ctor is good
  17. Iterator end() {
  18. static const Iterator endIter = ++Iterator(endVal); // cache it
  19. return endIter;
  20. }
  21. bool operator!=(const Iterator& i) { return val != i.val; }
  22. };
  23.  
  24. typedef Iterator<LtModeType, LtModeType_MIN, LtModeType_MAX> modeIterator;
Add Comment
Please, Sign In to add comment