mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
functional/hash/hash.hpp インクルードガードのエラー修正
hash クラスの実装をデフォルトで提供 functional/hash/string.hpp テンプレートパラメータのエラー修正
This commit is contained in:
parent
41916cf0a5
commit
9d7eecc585
2 changed files with 22 additions and 9 deletions
|
@ -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 <cstddef>
|
||||
#include <limits>
|
||||
|
@ -168,6 +168,21 @@ namespace sprout {
|
|||
;
|
||||
}
|
||||
|
||||
//
|
||||
// hash
|
||||
//
|
||||
template<typename T>
|
||||
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<type> { \
|
||||
|
@ -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 <class T>
|
||||
template<typename T>
|
||||
struct hash<T*> {
|
||||
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
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <sprout/string.hpp>
|
||||
|
||||
namespace sprout {
|
||||
template<typename T, std::size_t N, typename Traits = sprout::char_traits<T> >
|
||||
template<typename T, std::size_t N, typename Traits>
|
||||
SPROUT_CONSTEXPR std::size_t hash_value(sprout::basic_string<T, N, Traits> const& v) {
|
||||
return sprout::hash_range(v.begin(), v.end());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue