to give context i'm trying to re-implement vector
container, and while reading about it's iterator
system requirements, i've stumbled upon this requirement from cplusplus reference:
can be incremented (if in a dereferenceable state ). the result is either dereferenceable or past-the-end iterator.
EX: ++a , a++, *a++
i've already overloaded the increment
and dereference
operators as so:
class iterator {
...
inline iterator& operator++() {
++_ptr;
return *this;
};
inline iterator operator++(int) {
iterator tmp(*this);
operator++();
return (tmp);
};
inline reference operator*() const {
return _ptr;
};
...
}
i've researched a bit about this requirement and didn't found any informations mentioning this property, so i assumed it's irrelevant and handled by default by the compiler as long as i overload the operators separately, is that the case or should i implement my iterator in a way so that it can be incremented in a dereferenceable state.