Boost logo

Boost :

Subject: Re: [boost] [UTF String] UTF String library 1.5 ready for perusal
From: Thomas Klimpel (Thomas.Klimpel_at_[hidden])
Date: 2011-02-11 14:21:07


Chad Nelson wrote:
> Mathias Gaunard 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*.

A long time ago I asked on this list whether output iterator also has this requirement, because Boost.Iterator didn't declared an iterator an output iterator if this condition was not satisfied (thereby causing problems for Boost.MultiArray on MSVC-10). I'm now pretty sure that the requirement is definitively there for forward iterators and definitively absent for output iterators, so that the behavior of Boost.Iterator with respect to output iterators can at least be regarded as undesirable.

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*.

Regards,
Thomas


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk