Created
September 12, 2013 03:36
-
-
Save retep998/6532801 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T> | |
class numerical_iterator { | |
public: | |
numerical_iterator() : m_value {} { | |
} | |
numerical_iterator(numerical_iterator const & o) : m_value {o.m_value} { | |
} | |
numerical_iterator(numerical_iterator && o) : m_value {o.m_value} { | |
} | |
numerical_iterator(T const & o) : m_value {o} { | |
} | |
numerical_iterator(T && o) : m_value {o} { | |
} | |
~numerical_iterator() /*noexcept*/ { | |
} | |
numerical_iterator & operator=(numerical_iterator const & o) { | |
m_value = o.m_value; | |
} | |
numerical_iterator & operator=(numerical_iterator && o) { | |
m_value = o.m_value; | |
} | |
numerical_iterator & operator=(T const & o) { | |
m_value = o; | |
} | |
numerical_iterator & operator=(T && o) { | |
m_value = o; | |
} | |
bool operator==(numerical_iterator const & o) const { | |
return o.m_value == m_value; | |
} | |
bool operator!=(numerical_iterator const & o) const { | |
return o.m_value != m_value; | |
} | |
T const & operator*() const { | |
return m_value; | |
} | |
T const * operator->() const { | |
return &m_value; | |
} | |
numerical_iterator & operator++() { | |
++m_value; | |
return *this; | |
} | |
numerical_iterator operator++(int) { | |
return numerical_iterator {m_value++}; | |
} | |
private: | |
T m_value; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment