#ifndef _COMPARISONS_H #define _COMPARISONS_H // default comparison template <typename T> int Compare(T const & s, T const & t) { if (s > t) return 1; if (s < t) return -1; return 0; } // specialization for char *'s template <> int Compare(char * const & a, char * const & b) { char * s = a; char * t = b; while (1) { if (*s > *t) return 1; if (*s < *t) return -1; if (! (*s || *t)) return 0; ++s; ++t; } } // default equality test template <typename T> int Equal(T const &s, T const &t) { return Compare(s, t) == 0; } #endif