mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
modify: tuple and hash support(class adapt) implemented in each class headers.
This commit is contained in:
parent
3a2610cb5c
commit
ee8c952d05
35 changed files with 1720 additions and 1557 deletions
|
@ -1,16 +0,0 @@
|
|||
#ifndef SPROUT_FUNCTIONAL_HASH_ARRAY_HPP
|
||||
#define SPROUT_FUNCTIONAL_HASH_ARRAY_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/functional/hash/hash.hpp>
|
||||
#include <sprout/array.hpp>
|
||||
|
||||
namespace sprout {
|
||||
template<typename T, std::size_t N>
|
||||
SPROUT_CONSTEXPR std::size_t hash_value(sprout::array<T, N> const& v) {
|
||||
return sprout::hash_range(v.begin(), v.end());
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_HASH_ARRAY_HPP
|
|
@ -1,8 +0,0 @@
|
|||
#ifndef SPROUT_FUNCTIONAL_HASH_BITSET_HPP
|
||||
#define SPROUT_FUNCTIONAL_HASH_BITSET_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/functional/hash/hash.hpp>
|
||||
#include <sprout/bitset/hash.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_HASH_BITSET_HPP
|
|
@ -35,9 +35,9 @@ namespace sprout {
|
|||
typename T,
|
||||
typename sprout::enabler_if<std::is_pointer<typename std::remove_reference<T>::type>::value>::type
|
||||
>
|
||||
SPROUT_CONSTEXPR std::size_t hash_value(T&& v);
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_value(T&& v);
|
||||
template<typename T, std::size_t N>
|
||||
SPROUT_CONSTEXPR std::size_t hash_value(T const (&v)[N]);
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_value(T const (&v)[N]);
|
||||
|
||||
namespace hash_detail {
|
||||
template<typename T>
|
||||
|
@ -153,11 +153,11 @@ namespace sprout {
|
|||
typename T,
|
||||
typename sprout::enabler_if<std::is_pointer<typename std::remove_reference<T>::type>::value>::type = sprout::enabler
|
||||
>
|
||||
SPROUT_CONSTEXPR std::size_t hash_value(T&& v) {
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_value(T&& v) {
|
||||
return sprout::hash_detail::hash_value_pointer(v);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
SPROUT_CONSTEXPR std::size_t hash_value(T const (&v)[N]) {
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_value(T const (&v)[N]) {
|
||||
return sprout::hash_range(&v[0], &v[0] + N);
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ namespace sprout {
|
|||
// to_hash
|
||||
//
|
||||
template<typename T>
|
||||
SPROUT_CONSTEXPR std::size_t to_hash(T const& v) {
|
||||
inline SPROUT_CONSTEXPR std::size_t to_hash(T const& v) {
|
||||
using sprout::hash_value;
|
||||
return hash_value(v);
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ namespace sprout {
|
|||
// hash_combine
|
||||
//
|
||||
template<typename T>
|
||||
SPROUT_CONSTEXPR std::size_t hash_combine(std::size_t seed, T const& v) {
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_combine(std::size_t seed, T const& v) {
|
||||
return seed ^ (sprout::to_hash(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2));
|
||||
}
|
||||
|
||||
|
@ -182,11 +182,11 @@ namespace sprout {
|
|||
// hash_range
|
||||
//
|
||||
template<typename Iterator>
|
||||
SPROUT_CONSTEXPR std::size_t hash_range(Iterator first, Iterator last) {
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_range(Iterator first, Iterator last) {
|
||||
return sprout::hash_range(0, first, last);
|
||||
}
|
||||
template<typename Iterator>
|
||||
SPROUT_CONSTEXPR std::size_t hash_range(std::size_t seed, Iterator first, Iterator last) {
|
||||
inline SPROUT_CONSTEXPR std::size_t hash_range(std::size_t seed, Iterator first, Iterator last) {
|
||||
return first != last
|
||||
? sprout::hash_range(sprout::hash_combine(seed, *first), sprout::next(first), last)
|
||||
: seed
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
#ifndef SPROUT_FUNCTIONAL_HASH_PIT_HPP
|
||||
#define SPROUT_FUNCTIONAL_HASH_PIT_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/functional/hash/hash.hpp>
|
||||
#include <sprout/pit.hpp>
|
||||
|
||||
namespace sprout {
|
||||
template<typename Container>
|
||||
SPROUT_CONSTEXPR std::size_t hash_value(sprout::pit<Container> const& v) {
|
||||
return sprout::to_hash(v.elem);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_HASH_PIT_HPP
|
|
@ -1,8 +0,0 @@
|
|||
#ifndef SPROUT_FUNCTIONAL_HASH_STRING_HPP
|
||||
#define SPROUT_FUNCTIONAL_HASH_STRING_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/functional/hash/hash.hpp>
|
||||
#include <sprout/string/hash.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_HASH_STRING_HPP
|
|
@ -1,16 +0,0 @@
|
|||
#ifndef SPROUT_FUNCTIONAL_HASH_SUB_ARRAY_HPP
|
||||
#define SPROUT_FUNCTIONAL_HASH_SUB_ARRAY_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/functional/hash/hash.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
|
||||
namespace sprout {
|
||||
template<typename Container>
|
||||
SPROUT_CONSTEXPR std::size_t hash_value(sprout::sub_array<Container> const& v) {
|
||||
return sprout::hash_range(v.begin(), v.end());
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_HASH_SUB_ARRAY_HPP
|
|
@ -1,15 +0,0 @@
|
|||
#ifndef SPROUT_FUNCTIONAL_HASH_UUID_HPP
|
||||
#define SPROUT_FUNCTIONAL_HASH_UUID_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/functional/hash/hash.hpp>
|
||||
#include <sprout/uuid/uuid.hpp>
|
||||
|
||||
namespace sprout {
|
||||
SPROUT_CONSTEXPR std::size_t hash_value(sprout::uuids::uuid const& v) {
|
||||
return sprout::hash_range(v.begin(), v.end());
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_HASH_UUID_HPP
|
Loading…
Add table
Add a link
Reference in a new issue