Boost logo

Boost :

From: JOAQUIN LOPEZ MU?Z (joaquin_at_[hidden])
Date: 2007-05-12 19:24:55


----- Mensaje original -----
De: David Abrahams <dave_at_[hidden]>
Fecha: Domingo, Mayo 13, 2007 0:16 am
Asunto: Re: [boost] [iterator] Proposal to add is_const_iterator trait
Para: boost_at_[hidden]
>
> on Sat May 12 2007, Andrey Semashev <andysem-AT-mail.ru> wrote:
[...]
> >
> > I apologize for returning to this, but as I'm reading the docs and
> > looking at my use cases I have before me I don't see how would I
> > elide is_const_iterator when using iterator_adaptor. Suppose this:
> >
> > template< typename ValueT >
> > class MyList
> > {
> > public:
> > typedef ValueT value_type;
> >
> > // etc. all other common typedefs except iterators
> >
> > private:
> > struct MyNode
> > {
> > ValueT value;
> > int m_SomeOtherData;
> > };
> > typedef std::list< MyNode > underlying_container;
> >
> > template< typename >
> > class MyIterator;
> >
> > public:
> > typedef MyIterator<
> > typename underlying_container::iterator
> > > iterator;
> >
> > typedef MyIterator<
> > typename underlying_container::const_iterator
> > > const_iterator;
> >
> > private:
> > template< typename ItT >
> > class MyIterator :
> > public iterator_adaptor<
> > MyIterator< ItT >,
> > ItT,
> > value_type, // I have to substitute value type
>
> No, just leave it out. The default works.

I think this is the crux of the matter. value_type is *not*
the same type as underlying_container::value_type. I think
Andrey has a valid point here.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


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