mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
fix type: SPROUT_UNIQUE_SEED
This commit is contained in:
parent
2236d03165
commit
c0589d9925
1 changed files with 8 additions and 7 deletions
|
@ -2,6 +2,7 @@
|
|||
#define SPROUT_RANDOM_UNIQUE_SEED_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/array/array.hpp>
|
||||
|
@ -13,34 +14,34 @@ namespace sprout {
|
|||
// make_seed
|
||||
//
|
||||
template<typename T>
|
||||
SPROUT_CONSTEXPR std::size_t
|
||||
SPROUT_CONSTEXPR std::uint_least32_t
|
||||
make_seed(T const& v) {
|
||||
return sprout::to_hash(v);
|
||||
return static_cast<std::uint_least32_t>(sprout::to_hash(v));
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
template<std::size_t N, typename T, typename... Args>
|
||||
SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sizeof...(Args) + 1 == N,
|
||||
sprout::array<std::size_t, N>
|
||||
sprout::array<std::uint_least32_t, N>
|
||||
>::type
|
||||
make_seed_seq_impl(T const&, std::size_t seed, Args const&... args) {
|
||||
return sprout::array<std::size_t, N>{{args..., seed}};
|
||||
return sprout::array<std::uint_least32_t, N>{{args..., static_cast<std::uint_least32_t>(seed)}};
|
||||
}
|
||||
template<std::size_t N, typename T, typename... Args>
|
||||
SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sizeof...(Args) + 1 != N,
|
||||
sprout::array<std::size_t, N>
|
||||
sprout::array<std::uint_least32_t, N>
|
||||
>::type
|
||||
make_seed_seq_impl(T const& v, std::size_t seed, Args const&... args) {
|
||||
return sprout::detail::make_seed_seq_impl<N>(v, sprout::hash_combine(seed, v), args..., seed);
|
||||
return sprout::detail::make_seed_seq_impl<N>(v, sprout::hash_combine(seed, v), args..., static_cast<std::uint_least32_t>(seed));
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// make_seed_seq
|
||||
//
|
||||
template<std::size_t N, typename T>
|
||||
SPROUT_CONSTEXPR sprout::array<std::size_t, N>
|
||||
SPROUT_CONSTEXPR sprout::array<std::uint_least32_t, N>
|
||||
make_seed_seq(T const& v) {
|
||||
return sprout::detail::make_seed_seq_impl<N>(v, sprout::to_hash(v));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue