Boost C++ Libraries: Ticket #3151: Patch to graph library iterator handling https://svn.boost.org/trac10/ticket/3151 <p> I have developed some graph classes that generate edge lists on-the-fly (queried from a database). This means that my iterator ranges are not stable across calls to edges or out_edges. I have therefor altered the graph library to avoid comparing iterator across calls to vertices, edges, out_edges, etc. </p> <p> A common example occurs in a number of locations in the graph library: </p> <p> edge_iterator ei; for ( ei = out_edges(v, g).first, ei != out_edges(v, g).second, ++ei) { </p> <blockquote> <p> ... </p> </blockquote> <p> } </p> <p> Notice that ei is compared to subsequent calls to out_edges (this breaks my code). </p> <p> A synonymous change is to re-write this as: </p> <p> edge_iterator ei, e_end; for (tie(ei, e_end) = out_edges(v, g); ei != e_end; ++ei) { </p> <blockquote> <p> ... </p> </blockquote> <p> } </p> <p> The behavior of the code is not changed and is perhaps a bit easier to read. This version will not break my code because ei is only compared to e_end. </p> <p> I have tried to remove all occurrences of comparing iterators to (vertices|edges|out_edges|...)(...).second and replace them with code that only compares iterators from the same call to (vertices|edges|out_edges|...). </p> <p> I also added a file called pair_util.hpp which defines templates that make it easy to test whether members of a pair are equal or not equal. </p> <p> I am attaching a patch. I have run the graph regression tests and all pass except one that does not pass before the patch. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3151 Trac 1.4.3 tkeitt@… Mon, 08 Jun 2009 20:00:37 GMT attachment set https://svn.boost.org/trac10/ticket/3151 https://svn.boost.org/trac10/ticket/3151 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">bgl.diff</span> </li> </ul> <p> svn diff </p> Ticket Jeremiah Willcock Mon, 08 Jun 2009 21:06:20 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3151#comment:1 https://svn.boost.org/trac10/ticket/3151#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/53761" title="Fixed issues from ticket #3151 (some using the patch there and some in ...">[53761]</a>) Fixed issues from ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3151" title="#3151: Patches: Patch to graph library iterator handling (closed: fixed)">#3151</a> (some using the patch there and some in other ways); fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3151" title="#3151: Patches: Patch to graph library iterator handling (closed: fixed)">#3151</a>, refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3134" title="#3134: Patches: BGL patches to move into 1.40 (closed: fixed)">#3134</a> </p> Ticket