From 9d7eecc585ea83b84cba7c1898c29cb3aad9441e Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Sat, 29 Oct 2011 11:05:42 +0900 Subject: [PATCH] =?UTF-8?q?functional/hash/hash.hpp=20=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=82=AF=E3=83=AB=E3=83=BC=E3=83=89=E3=82=AC=E3=83=BC=E3=83=89?= =?UTF-8?q?=E3=81=AE=E3=82=A8=E3=83=A9=E3=83=BC=E4=BF=AE=E6=AD=A3=20hash?= =?UTF-8?q?=20=E3=82=AF=E3=83=A9=E3=82=B9=E3=81=AE=E5=AE=9F=E8=A3=85?= =?UTF-8?q?=E3=82=92=E3=83=87=E3=83=95=E3=82=A9=E3=83=AB=E3=83=88=E3=81=A7?= =?UTF-8?q?=E6=8F=90=E4=BE=9B=20functional/hash/string.hpp=20=E3=83=86?= =?UTF-8?q?=E3=83=B3=E3=83=97=E3=83=AC=E3=83=BC=E3=83=88=E3=83=91=E3=83=A9?= =?UTF-8?q?=E3=83=A1=E3=83=BC=E3=82=BF=E3=81=AE=E3=82=A8=E3=83=A9=E3=83=BC?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sprout/functional/hash/hash.hpp | 29 +++++++++++++++++++++-------- sprout/functional/hash/string.hpp | 2 +- 2 files changed, 22 insertions(+), 9 deletions(-) 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()); }