Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-09-25 08:28:15


From: "Douglas Gregor" <gregod_at_[hidden]>
> On Tuesday 24 September 2002 07:18 pm, Bohdan wrote:
> > "Douglas Gregor" <gregod_at_[hidden]> wrote in message
> > > ... or just iterator_traits extended to allow trivial iterators.
> > > boost/iterator_traits.hpp, anyone?
> >
> > IMHO i like this idea. The simplest solutions are always the best , but
> > are you sure that this two idioms (iterators & pointers ) should be
mixed ?
> > Does standart allow such iterators ?
> >
> > PS: not too serious:
> > If "anyone" implements iterator_traits for a smart_ptr, than
> > what will be the name for its iterator category:
> > "uninterative_iterator_category" ?
>
> trivial_iterator_tag
>
> See the TrivialIterator concept documentation here:
> http://www.sgi.com/tech/stl/trivial.html

I think that a separate dereference_traits (or whatever) class would be
better. Trivial iterators aren't required to return a reference when
dereferenced, and I think that iterator_traits<TrivialIterator> is
deliberately left undefined as most of the members don't make sense. In
addition, the value_type of an iterator is always non-const, whereas the
element_type of a pointer is traditionally the exact template parameter,
including cv qualifiers.

Bundling a set of traits in a single class inevitably creates problems. I'm
leaning towards element_type_of<P>::type (template parameter of P or T in
T*) and reference_of<P>::type (exact return type of *p, typically
element_type_of<P>::type &, but may be proxy.)


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