"Marshall Clow" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> "Joe Gottman" <[EMAIL PROTECTED]> wrote:
> >Suppose I have a vector<Foo *> and I want to use indirect_iterator to
create
> >an iterator that allows the user to read but not modify the objects
pointed
> >to by elements of the vector.  In other words, I want to do the
following:
> >   typedef /*whatever */ my_iterator;
> >   my_iterator it(theVector.begin());
> >   const Foo &foo = *it;
> >
> >    But I want
> >          *it = Foo();
> >to fail.  Also, if possible I would like this new type to interact with
> >      indirect_iterator<vector<Foo *>::iterator>
> >in the expected way.
> >
> >   I'm sure this is possible, but the documentation doesn't really say
how to
> >do it.
>
> is there some reason you can't use const_iterator?
>

    const_iterator doesn't do what I want.  Consider the following code:
          vector<Foo *>::const_iterator theIterator =  myVector.begin();
          **theIterator = Foo();

This code should compile fine, since it's not changing the value of
*theIterator.  This is why most smart pointers have operator* and operator->
defined as const member functions.

Joe Gottman




_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to