Boost C++ Libraries: Ticket #5659: The closed_plus structure should accept a custom infinity value. https://svn.boost.org/trac10/ticket/5659 <p> I'm trying to run dijkstra_shortest_paths with a custom distance type (my graph supports two metrics, I want to find the length in metric A of the shortest paths according to metric B). </p> <p> I've been struggling to understand why I was getting dependencies on <a class="missing wiki">MyDistType</a>(int). It turns out that overloading + on <a class="missing wiki">MyDistType</a> is only half the story. The default combine operator for distances comes from closed_plus, which assumes an infinity value can be constructed by std::numeric_limits&lt;D&gt;::max(). This function seems to degrade to trying the constructor T(n) for some int n (probably INT_MAX) if it isn't a known numeric type, leading to bizarre errors (buried under piles of template goop). </p> <p> This patch gives instances of closed_plus a parameter to store the custom infinity value, defaulting to the one from std::numeric_limits. It also passes the correct default value in dijkstra_shortest_paths. I haven't checked whether any of the other algorithms that use closed_plus can potentially have non-standard infinity values. </p> <p> Hope you agree this is an improvement. </p> <p> Yours, </p> <blockquote> <p> Thomas. </p> </blockquote> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5659 Trac 1.4.3 Thomas Sewell <thomas.sewell@…> Wed, 29 Jun 2011 14:12:06 GMT attachment set https://svn.boost.org/trac10/ticket/5659 https://svn.boost.org/trac10/ticket/5659 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">diff</span> </li> </ul> <p> diff </p> Ticket Thomas Sewell <thomas.sewell@…> Thu, 30 Jun 2011 05:56:38 GMT <link>https://svn.boost.org/trac10/ticket/5659#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5659#comment:1</guid> <description> <p> An alternative fix, of course, would be to make it clear in the documentation of dijkstra_shortest_paths and similar that if you supply your own distance_inf then you *must* supply your own distance_combine, and/or to mandate that with a compile-time assertion in the named parameters interpreter. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Thu, 07 Jul 2011 20:14:18 GMT</pubDate> <title>owner, status changed https://svn.boost.org/trac10/ticket/5659#comment:2 https://svn.boost.org/trac10/ticket/5659#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Andrew Sutton</span> to <span class="trac-author">Jeremiah Willcock</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Jeremiah Willcock Thu, 07 Jul 2011 21:07:45 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5659#comment:3 https://svn.boost.org/trac10/ticket/5659#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</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/72960" title="Applied patch from #5659, plus made similar changes to other ...">[72960]</a>) Applied patch from <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5659" title="#5659: Bugs: The closed_plus structure should accept a custom infinity value. (closed: fixed)">#5659</a>, plus made similar changes to other algorithms that have inf parameters; did not add inf parameters to algorithms that did not already have them; fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5659" title="#5659: Bugs: The closed_plus structure should accept a custom infinity value. (closed: fixed)">#5659</a> </p> Ticket