Skip to content

Instantly share code, notes, and snippets.

@retep998
Created September 12, 2013 03:36
Show Gist options
  • Save retep998/6532801 to your computer and use it in GitHub Desktop.
Save retep998/6532801 to your computer and use it in GitHub Desktop.
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