diff --git a/dtool/src/dtoolbase/stl_compares.I b/dtool/src/dtoolbase/stl_compares.I index 7e9603883f..ec5d0c79b6 100644 --- a/dtool/src/dtoolbase/stl_compares.I +++ b/dtool/src/dtoolbase/stl_compares.I @@ -83,8 +83,6 @@ operator () (const Key &a, const Key &b) const { return (a != b && (*a).get_name() < (*b).get_name()); } -#ifdef HAVE_STL_HASH - //////////////////////////////////////////////////////////////////// // Function: integer_hash::add_hash // Access: Public, Static @@ -162,7 +160,7 @@ operator () (const Key &key) const { template INLINE size_t sequence_hash:: add_hash(size_t hash, const Key &key) { - Key::const_iterator ki; + TYPENAME Key::const_iterator ki; for (ki = key.begin(); ki != key.end(); ++ki) { hash = (hash * 31) + (size_t)(*ki); } @@ -190,5 +188,3 @@ INLINE size_t indirect_method_hash:: operator () (const Key &key) const { return (*key).get_hash(); } - -#endif // HAVE_STL_HASH diff --git a/dtool/src/dtoolbase/stl_compares.h b/dtool/src/dtoolbase/stl_compares.h index c4aad15bdc..882633acc8 100644 --- a/dtool/src/dtoolbase/stl_compares.h +++ b/dtool/src/dtoolbase/stl_compares.h @@ -24,8 +24,22 @@ #include "nearly_zero.h" #ifdef HAVE_STL_HASH -#include -#include +#include // for hash_compare + +#define stl_hash_compare hash_compare + +#else + +#include // for less + +// This is declared for the cases in which we don't have STL_HASH +// available--it's just a name to inherit from, but there's no need to +// provide much functionality in the base class (since it won't +// actually be used for hashing, just for comparing). +template > +class stl_hash_compare : public Compare { +}; + #endif // HAVE_STL_HASH //////////////////////////////////////////////////////////////////// @@ -95,8 +109,6 @@ public: INLINE bool operator () (const Key &a, const Key &b) const; }; -#ifdef HAVE_STL_HASH - //////////////////////////////////////////////////////////////////// // Class : integer_hash // Description : This is the default hash_compare class, which assumes @@ -106,7 +118,7 @@ public: // system-provided hash_compare. //////////////////////////////////////////////////////////////////// template > -class integer_hash : public hash_compare { +class integer_hash : public stl_hash_compare { public: INLINE static size_t add_hash(size_t start, const Key &key); }; @@ -116,7 +128,7 @@ public: // Description : This hash_compare class hashes a float or a double. //////////////////////////////////////////////////////////////////// template -class floating_point_hash : public hash_compare { +class floating_point_hash : public stl_hash_compare { public: INLINE floating_point_hash(Key threshold = get_nearly_zero_value((Key)0)); INLINE size_t operator () (const Key &key) const; @@ -132,11 +144,11 @@ public: // methods that iterate through Key::value_type. //////////////////////////////////////////////////////////////////// template > -class sequence_hash : public hash_compare { +class sequence_hash : public stl_hash_compare { public: INLINE size_t operator () (const Key &key) const; INLINE bool operator () (const Key &a, const Key &b) const { - return hash_compare::operator () (a, b); + return stl_hash_compare::operator () (a, b); } INLINE static size_t add_hash(size_t start, const Key &key); }; @@ -148,11 +160,11 @@ public: // that returns a size_t. //////////////////////////////////////////////////////////////////// template > -class method_hash : public hash_compare { +class method_hash : public stl_hash_compare { public: INLINE size_t operator () (const Key &key) const; INLINE bool operator () (const Key &a, const Key &b) const { - return hash_compare::operator () (a, b); + return stl_hash_compare::operator () (a, b); } }; @@ -164,36 +176,14 @@ public: // a size_t. //////////////////////////////////////////////////////////////////// template -class indirect_method_hash : public hash_compare { +class indirect_method_hash : public stl_hash_compare { public: INLINE size_t operator () (const Key &key) const; INLINE bool operator () (const Key &a, const Key &b) const { - return hash_compare::operator () (a, b); + return stl_hash_compare::operator () (a, b); } }; -#else // HAVE_STL_HASH - -// If the STL doesn't provide any hash methods, then all of the above -// simply map to their Compare function. -template > -class floating_point_hash : public Compare { -}; -template > -class integer_hash : public Compare { -}; -template > -class sequence_hash : public Compare { -}; -template > -class method_hash : public Compare { -}; -template -class indirect_method_hash : public Compare { -}; - -#endif // HAVE_STL_HASH - #include "stl_compares.I" typedef floating_point_hash float_hash;