Boost logo

Boost Users :

From: Keith MacDonald (boost_at_[hidden])
Date: 2004-01-07 16:06:18


Your patch solves my immediate problem, thanks. Fortunately, both the
classes that I need iterators for only require bidirectional semantics, so
the random access issue does not arise, but thanks for pointing it out.

Keith MacDonald

"David Abrahams" <dave_at_[hidden]> wrote in message
news:uoetfa7th.fsf_-__at_boost-consulting.com...
> "Keith MacDonald" <boost_at_[hidden]> writes:
>
> > I've done that, and attach the new source. However, I hereby relinquish
all
> > rights over baz2.cpp, so feel free to do whatever you like with it.
> >
> > When I attempted to integrate the iterators with my actual code, I hit a
> > problem that I don't know how to resolve with iterator_facade. To
> > illustrate it, I've modified the example code and attach it as baz3.cpp.
> > Now, Node is an abstract base class, and DerivedNode is instantiated.
> > Compiling it results in the following error:
> >
> > \CVS\boost\boost\iterator\iterator_facade.hpp(389) : error C2259:
> > 'Node' : cannot instantiate abstract class due to following members:
> > 'int Node::getInfo(void) const' : pure virtual function was not defined
> >
> > Can your technique be used in such contexts?
>
> Very interesting case. The problem is that, when the iterator is not
> writable, operator[] returns an object of the iterator's
> value_type. In this case the value_type is abstract, so it can't be
> returned.
>
> This raises several problems that I can see.
>
> 1. Obviously, the library doesn't work for you. You can get around
> that by applying the enclosed patch to iterator_facade.hpp. We'll
> figure out the right long-term fix soon; this one might be it.
>
> 2. We have to re-think the readable iterator requirements if we want
> iterators over abstract types to be legal. My feeling is that the
> requirement should be that *a is convertible to value_type const&.
>
> 3. Your iterator isn't a legal random access iterator, because the
> random access iterator requirements say that a[n] must be
> convertible to value_type. You can't convert anything to
> value_type in this case, since it can't be constructed. I think
> this is a defect in the current standard, and will submit a DR.
>
>

----------------------------------------------------------------------------

----
>
> -- 
> Dave Abrahams
> Boost Consulting
> www.boost-consulting.com
>
----------------------------------------------------------------------------
----
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

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