#pragma once /** * Iterator interface * \tparam T type of the value that is iterated * \tparam I type of the iterator subclass */ template class Iterator { public: virtual ~Iterator() { static_assert(std::is_base_of::value, "Type Argument I must be an implementation of Iterator"); } virtual bool hasNext() { return (bool)next(); } virtual I next() = 0; virtual operator bool() = 0; virtual I& operator++() //! prefix { *(I*)this = next(); return *(I*)this; } virtual I operator++(int) //! postfix { I tmp(*(I*)this); operator++(); return tmp; } virtual T val() = 0; virtual void set(T val) = 0; virtual void remove() = 0; operator T() { return val(); } virtual T operator->() { return val(); } virtual T operator*() { return val(); } };