From 921850c029bdaad568b0e40969b0805df785b72a Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Wed, 1 Jun 2005 09:20:33 +0000 Subject: [PATCH] changing back, and including locale --- action.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/action.h b/action.h index a0a1173..32fbcb9 100644 --- a/action.h +++ b/action.h @@ -4,6 +4,7 @@ #include #include #include +#include typedef std::vector Literals; typedef __gnu_cxx::hash_map Preconditions; @@ -15,10 +16,9 @@ namespace __gnu_cxx { struct hash< std::basic_string > { size_t operator()(const std::basic_string& s) const { - size_t hash = 0; - for (unsigned int i = 0; i < s.size(); ++i) - hash += static_cast(s[i]); - return hash + s.size(); + const std::collate& c = std::use_facet< std::collate >(std::locale()); + + return c.hash(s.c_str(), s.c_str() + s.size()); } @@ -29,10 +29,9 @@ namespace __gnu_cxx { size_t operator()(const std::basic_string& s) const { - size_t hash = 0; - for (unsigned int i = 0; i < s.size(); ++i) - hash += static_cast(s[i]); - return hash + s.size(); + const std::collate& c = std::use_facet< std::collate >(std::locale()); + + return c.hash(s.c_str(), s.c_str() + s.size()); } }; -- 2.39.2