#ifndef SPROUT_FUNCTIONAL_HASH_HASH_HPP #define SPROUT_FUNCTIONAL_HASH_HASH_HPP #include #include #include #include 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 { return sprout::to_hash(v); } }; template struct hash : public sprout::hash {}; template struct hash : public sprout::hash {}; template struct hash : public sprout::hash {}; #define SPROUT_HASH_SPECIALIZE(type) \ template<> \ struct hash { \ public: \ typedef type argument_type; \ typedef std::size_t result_type; \ public: \ SPROUT_CONSTEXPR std::size_t operator()(type v) const { \ return sprout::to_hash(v); \ } \ } #define SPROUT_HASH_SPECIALIZE_REF(type) \ template<> \ struct hash { \ public: \ typedef type argument_type; \ typedef std::size_t result_type; \ public: \ SPROUT_CONSTEXPR std::size_t operator()(type const& v) const { \ return sprout::to_hash(v); \ } \ } SPROUT_HASH_SPECIALIZE(bool); SPROUT_HASH_SPECIALIZE(char); SPROUT_HASH_SPECIALIZE(signed char); SPROUT_HASH_SPECIALIZE(unsigned char); SPROUT_HASH_SPECIALIZE(char16_t); SPROUT_HASH_SPECIALIZE(char32_t); SPROUT_HASH_SPECIALIZE(wchar_t); SPROUT_HASH_SPECIALIZE(short); SPROUT_HASH_SPECIALIZE(unsigned short); SPROUT_HASH_SPECIALIZE(int); SPROUT_HASH_SPECIALIZE(unsigned int); SPROUT_HASH_SPECIALIZE(long); SPROUT_HASH_SPECIALIZE(unsigned long); SPROUT_HASH_SPECIALIZE(long long); SPROUT_HASH_SPECIALIZE(unsigned long long); #undef SPROUT_HASH_SPECIALIZE #undef SPROUT_HASH_SPECIALIZE_REF template struct hash { public: typedef T* argument_type; typedef std::size_t result_type; public: std::size_t operator()(T* v) const { return sprout::to_hash(v); } }; } // namespace sprout #endif // #ifndef SPROUT_FUNCTIONAL_HASH_HASH_HPP