Update of /cvsroot/boost/boost/boost/graph
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv13187

Modified Files:
        relax.hpp 
Log Message:
Fix overflow handling with negative values as reported in 
http://lists.boost.org/boost-users/2007/05/28205.php

Index: relax.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/graph/relax.hpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- relax.hpp   6 Feb 2006 22:12:57 -0000       1.25
+++ relax.hpp   29 May 2007 15:22:29 -0000      1.26
@@ -22,16 +22,13 @@
     template <class T>
     struct closed_plus
     {
-      // std::abs just isn't portable :(
-      template <class X>
-      inline X my_abs(const X& x) const { return x < 0 ? -x : x; }
-
       T operator()(const T& a, const T& b) const {
         using namespace std;
-        T inf = (numeric_limits<T>::max)();
-        if (b > 0 && my_abs(inf - a) < b)
-          return inf;
-        return a + b;
+       T zero(0);
+       T result = a + b;
+       if (result < zero && a >= zero && b >= zero)
+         return (numeric_limits<T>::max)();
+       return result;
       }
     };
     


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs

Reply via email to