Boost logo

Boost Users :

Subject: Re: [Boost-users] MultiPassInputIterator concept
From: David Abrahams (dave_at_[hidden])
Date: 2008-11-11 23:41:11


on Tue Nov 11 2008, "Tim Keitt" <tkeitt-AT-keittlab.org> wrote:

> I have a question about the requirements of the MultiPassInputIterator
> concept as used in the Boost Graph Library. Does the ++first_iter ==
> ++second_iter requirement hold across calls to out_edges(vertex, g)?
> Or put another way, does out_edges always have to return an iterator
> with same ordering of returned edges?
>
> The difference is between:
>
> graph_traits<graph>::out_edge_iterator i = out_edges(vertex, g);
> graph_traits<graph>::out_edge_iterator j = i;
> ++i == ++j; // clearly required, but sufficient?
>
> and
>
> graph_traits<graph>::out_edge_iterator i = out_edges(vertex, g);
> graph_traits<graph>::out_edge_iterator j = out_edges(vertex, g);
> ++i == ++j; // also required?
>
> Strangely enough, I have an application where the second case is
> (currently) not guaranteed (its a custom graph class where the
> out_edge_iterator is constructed on-the-fly).

I don't think any code is relying on the 2nd case, but it's hard to be
sure. You could check for it by adding a generation counter in the
iterator and assert if two iterators from different generations are
compared. After all, they are effectively iterating different
sequences.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

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