[Boost-bugs] [Boost C++ Libraries] #5659: The closed_plus structure should accept a custom infinity value.

Subject: [Boost-bugs] [Boost C++ Libraries] #5659: The closed_plus structure should accept a custom infinity value.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-06-29 14:11:09


#5659: The closed_plus structure should accept a custom infinity value.
--------------------------------------------------------+-------------------
 Reporter: Thomas Sewell <thomas.sewell@…> | Owner: asutton
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: graph
  Version: Boost 1.46.1 | Severity: Problem
 Keywords: |
--------------------------------------------------------+-------------------
 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).

 I've been struggling to understand why I was getting dependencies on
 MyDistType(int). It turns out that overloading + on MyDistType 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<D>::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).

 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.

 Hope you agree this is an improvement.

 Yours,
     Thomas.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5659>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:06 UTC