When dealing with pointers, pointers to one past the end have (mostly) defined behavior:
int array[8];
int* x = array + 8; // Still considered pointing to part of array in expressions
Iterators make use of this by comparing the iterator pointer to the one past the end.
Reverse iterators do the same thing, but to one before the start of the array:
int array[8];
int* x = array - 1;
Isn’t this undefined behavior? Do containers hold an extra element and consider [1] the start?
Reverse iterators aren’t really iterators. They’re more like “iterator adapters”. You can call the
base()member function on a reverse iterator in order to get a real iterator back, and this incurs a -1 offset, so thatrbegin().base() == end()andrend().base() == begin(). Therefore, there is no need for an explicit “before the beginning” pointer value or something like that. (With the exception offorward_listof course.)