]> www.ginac.de Git - ginac.git/commitdiff
synced to 1.2
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Sat, 7 Jun 2003 00:47:49 +0000 (00:47 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Sat, 7 Jun 2003 00:47:49 +0000 (00:47 +0000)
ginac/utils.h

index f21dfed4f35cb5f04399e3c8c0ed4a9631d0c30f..c81c88886249d9079eac222c2a6734c0898c040b 100644 (file)
@@ -28,6 +28,8 @@
 
 #include <string>
 #include <stdexcept>
+#include <functional>
+
 #include "assertion.h"
 
 namespace GiNaC {
@@ -56,11 +58,14 @@ unsigned log2(unsigned n);
 
 /** Compare two pointers (just to establish some sort of canonical order).
  *  @return -1, 0, or 1 */
-inline int compare_pointers(const void * a, const void * b)
+template <class T>
+inline int compare_pointers(const T * a, const T * b)
 {
-       if (a<b)
+       // '<' is not defined for pointers that don't point to the same array,
+       // but std::less is.
+       if (std::less<const T *>()(a, b))
                return -1;
-       else if (a>b)
+       else if (std::less<const T *>()(b, a))
                return 1;
        return 0;
 }