Boost logo

Boost Users :

From: Jeremy Graham Siek (jsiek_at_[hidden])
Date: 2005-01-16 18:53:24


Hi Felipe,

The counting_iterator is not meant to be used for creating mutable
iterators.
You should use iterator_adaptor instead.

Cheers,
Jeremy

On Jan 16, 2005, at 1:50 AM, Felipe Magno de Almeida wrote:

> I'm trying to create an iterator from a class that is almost an
> iterator, it worked fine for const iterator with counting_iterator,
> but when I needed to dereference it, it complained about this:
> error C2440: 'return' : cannot convert from 'const
> xmlmanager::xml_basic_node<T>' to
> 'boost::
> iterator_facade<Derived,Value,CategoryOrTraversal,Reference,Difference>
> ::reference'
> I think it is because it is still a const iterator...
> But I need a mutable iterator, and I have no clue in how to do it...
> I've tried the documentation, but it just explains what it is, but not
> ho to do it. The way I'm doing the iterator is:
>
> template <typename T>
> class xml_basic_node : public xml_basic_container<T>,
> public
> boost::iterator<boost::iterator_archetypes::
> readable_lvalue_iterator_t, xml_basic_node<T> >
> {
> public:
> // some specifics constructors
>
> bool operator == (xml_basic_node<T> const &n) const
> {
> // compares equality
> }
>
> xml_basic_node<T> &operator ++()
> {
> // advances...
> return *this;
> }
> };
> and the iterator through counting_iterator:
> template <typename T>
> class acontainer {
> typedef boost::counting_iterator<xml_basic_node<T> > iterator;
> };
>
> If someone could, please point me where I am getting wrong... I am
> days already trying to figure out how to do it...
>
> Sorry for the size of the mail and thanks in advance.
>
> --
> Felipe Magno de Almeida
> UIN: 2113442
> email: felipe.almeida_at_ic unicamp br, felipe.m.almeida_at_gmail com
> I am a C, modern C++, MFC, ODBC, Windows Services, MAPI developer
> from synergy, and Computer Science student from State
> University of Campinas(UNICAMP).
> To know more about:
> Unicamp: http://www.ic.unicamp.br
> Synergy: http://www.synergy.com.br
> current work: http://www.mintercept.com
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
_______________________________________________
Jeremy Siek <jsiek_at_[hidden]>
http://www.osl.iu.edu/~jsiek
Ph.D. Candidate, Indiana University Bloomington
C++ Booster (http://www.boost.org)
_______________________________________________


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net