From 3ab397171fb7ca39c6cf075adfe41f02305f82c0 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Thu, 7 Feb 2013 23:39:57 +0900 Subject: [PATCH] add polymorphic hash functor --- sprout/functional/hash/hash.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sprout/functional/hash/hash.hpp b/sprout/functional/hash/hash.hpp index e8d27df4..3adb75c9 100644 --- a/sprout/functional/hash/hash.hpp +++ b/sprout/functional/hash/hash.hpp @@ -5,6 +5,7 @@ #include #include #include +#include namespace sprout { // @@ -32,6 +33,19 @@ namespace sprout { struct hash : public sprout::hash {}; + template<> + struct hash { + public: + typedef std::size_t result_type; + public: + template + SPROUT_CONSTEXPR std::size_t + operator()(T&& v) + const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::to_hash(sprout::forward(v)))) + { + return sprout::to_hash(sprout::forward(v)); + } + }; #define SPROUT_HASH_SPECIALIZE(type) \ template<> \