
On Fri, 11 Feb 2011 20:21:07 +0100 Thomas Klimpel <Thomas.Klimpel@synopsys.com> wrote:
Chad Nelson wrote:
I'm not a fan of returning a reference in operator* as well.
No choice in that, I ran into at least one STL algorithm under GCC that wouldn't compile if it wasn't a reference, even when it was only being read. I don't remember which one, but it was something important and commonly-used enough that breaking it was not an option.
To satisfy the requirements of a forward iterator, you must return a reference in operator*. [...] The take-away for this discussion is that forward iterator and any of its refinements like bidirectional iterator and random access iterator have to return a reference in operator*.
That would certainly explain the behavior I saw. Thanks for the information. -- Chad Nelson Oak Circle Software, Inc. * * *