Topic: reverse_iterator.base()


Author: jpotter@falcon.lhup.edu (John Potter)
Date: 2000/10/11
Raw View
On Wed, 11 Oct 2000 13:34:37 GMT, Simon Brady
<sjbrady@spam-me-not.acm.org> wrote:

> wouldn't it
> make more sense for base() to return i-1? Or is my intuition simply
> flawed?

Consider: container.rend().base().  I don't think you want begin() - 1.

John

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]






Author: Simon Brady <sjbrady@spam-me-not.acm.org>
Date: 2000/10/11
Raw View
24.4.1 states:

"The fundamental relation between a reverse iterator and its
corresponding iterator i is established by the identity:
&*(reverse_iterator(i)) == &*(i - 1)."

Stroustrup, 16.3.2 (p445), says that reverse_iterator.base() "returns an
iterator corresponding to the reverse_iterator." However, by
24.4.1.3.{1,2} we have reverse_iterator(i).base() == i, which has the
IMO counter-intuitive consequence that &*(reverse_iterator(i)) !=
&*(reverse_iterator(i).base()). Although Stroustrup is correct if you
read "corresponding" in the specialised sense of 24.4.1, wouldn't it
make more sense for base() to return i-1? Or is my intuition simply
flawed?

Thanks for any insights...
Simon Brady                                            sjbrady
Research Assistant, Computer Science Dept.               at
University of Otago, Dunedin, New Zealand            acm dot org

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]