#ifndef SPROUT_RANDOM_UNIQUE_SEED_HPP #define SPROUT_RANDOM_UNIQUE_SEED_HPP #include #include #include #include #include #include namespace sprout { // // make_seed // template SPROUT_CONSTEXPR std::size_t make_seed(T const& v) { return sprout::to_hash(v); } namespace detail { template SPROUT_CONSTEXPR typename std::enable_if< sizeof...(Args) + 1 == N, sprout::array >::type make_seed_seq_impl(T const&, std::size_t seed, Args const&... args) { return sprout::array{{args..., seed}}; } template SPROUT_CONSTEXPR typename std::enable_if< sizeof...(Args) + 1 != N, sprout::array >::type make_seed_seq_impl(T const& v, std::size_t seed, Args const&... args) { return sprout::detail::make_seed_seq_impl(v, sprout::hash_combine(seed, v), args..., seed); } } // namespace detail // // make_seed_seq // template SPROUT_CONSTEXPR sprout::array make_seed_seq(T const& v) { return sprout::detail::make_seed_seq_impl(v, sprout::to_hash(v)); } } // namespace sprout // // SPROUT_UNIQUE_SEED // #define SPROUT_UNIQUE_SEED (::sprout::make_seed(SPROUT_PP_UNIQUE_STRING)) // // SPROUT_UNIQUE_SEED_SEQ // #define SPROUT_UNIQUE_SEED_SEQ(N) (::sprout::make_seed_seq(SPROUT_PP_UNIQUE_STRING)) #endif // #ifndef SPROUT_RANDOM_UNIQUE_SEED_HPP