Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-09-25 09:49:48


From: "Douglas Gregor" <gregod_at_[hidden]>

> On Wednesday 25 September 2002 09:28 am, Peter Dimov wrote:
> > From: "Douglas Gregor" <gregod_at_[hidden]>
> > > 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,
>
> We already need a separate dereference_traits for iterators because of
this
> problem.
>
> > and I think that iterator_traits<TrivialIterator> is
> > deliberately left undefined as most of the members don't make sense.
>
> difference_type doesn't make sense, of course, but the others? value_type
is
> obviously necessary, reference is just add_reference<value_type>::type;

Not neccessarily. Input iterators may have a non-reference 'reference'
type.
Output iterators may have a void 'reference' type.
(IIRC)

> > 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.
>
> Er? const_iterators have a const value_type.

No, Peter's right.

> And what about iterator_traits<T const *>?

Its value_type is T.

> > 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.)
>
> Bundling traits does create problems, but so does having a huge number of
> separate traits classes that one needs to remember.

Naw, I like that organization. Also works well with MPL. Metaprogramming
with multi-valued trait metafunctions is very messy.

-----------------------------------------------------------
           David Abrahams * Boost Consulting
dave_at_[hidden] * http://www.boost-consulting.com


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