From: Michael Andreen Date: Wed, 1 Jun 2005 09:20:33 +0000 (+0000) Subject: changing back, and including locale X-Git-Url: https://ruin.nu/git/?p=popboot.git;a=commitdiff_plain;h=921850c029bdaad568b0e40969b0805df785b72a changing back, and including locale --- 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()); } };