diff --git a/sprout/functional/hash/hash.hpp b/sprout/functional/hash/hash.hpp index 93b387fd..e2ac263a 100644 --- a/sprout/functional/hash/hash.hpp +++ b/sprout/functional/hash/hash.hpp @@ -1,5 +1,5 @@ -#ifndef SPROUT_FUNCTIONAL_HASH_HPP -#define SPROUT_FUNCTIONAL_HASH_HPP +#ifndef SPROUT_FUNCTIONAL_HASH_HASH_HPP +#define SPROUT_FUNCTIONAL_HASH_HASH_HPP #include #include @@ -168,6 +168,21 @@ namespace sprout { ; } + // + // hash + // + template + struct hash { + public: + typedef T argument_type; + typedef std::size_t result_type; + public: + SPROUT_CONSTEXPR std::size_t operator()(T const& v) const { + using sprout::hash_value; + return hash_value(v); + } + }; + #define SPROUT_HASH_SPECIALIZE(type) \ template<> \ struct hash { \ @@ -191,9 +206,6 @@ namespace sprout { } \ } - // - // hash - // SPROUT_HASH_SPECIALIZE(bool); SPROUT_HASH_SPECIALIZE(char); SPROUT_HASH_SPECIALIZE(wchar_t); @@ -211,17 +223,18 @@ namespace sprout { #undef SPROUT_HASH_SPECIALIZE #undef SPROUT_HASH_SPECIALIZE_REF - template + template struct hash { public: typedef T* argument_type; typedef std::size_t result_type; public: SPROUT_CONSTEXPR std::size_t operator()(T* v) const { - return sprout::hash_value(v); + using sprout::hash_value; + return hash_value(v); } }; } //namespace sprout -#endif // #ifndef SPROUT_FUNCTIONAL_HASH_HPP +#endif // #ifndef SPROUT_FUNCTIONAL_HASH_HASH_HPP diff --git a/sprout/functional/hash/string.hpp b/sprout/functional/hash/string.hpp index 84cdea1b..eff4f892 100644 --- a/sprout/functional/hash/string.hpp +++ b/sprout/functional/hash/string.hpp @@ -7,7 +7,7 @@ #include namespace sprout { - template > + template SPROUT_CONSTEXPR std::size_t hash_value(sprout::basic_string const& v) { return sprout::hash_range(v.begin(), v.end()); }