/*============================================================================= Copyright (c) 2011-2017 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef SPROUT_FUNCTIONAL_HASH_HASH_RANGE_HPP #define SPROUT_FUNCTIONAL_HASH_HASH_RANGE_HPP #include #include #include #include #include #include #include namespace sprout { // // hash_combine_accumulator // template struct hash_combine_accumulator { public: typedef T first_argument_type; typedef T result_type; public: template SPROUT_CONSTEXPR T operator()(T const& seed, U const& v) const { return sprout::hash_combine(seed, v); } }; // // hash_range // template inline SPROUT_CONSTEXPR std::size_t hash_range(std::size_t seed, InputIterator first, InputIterator last) { return sprout::accumulate(first, last, seed, sprout::hash_combine_accumulator<>()); } template inline SPROUT_CONSTEXPR std::size_t hash_range(InputIterator first, InputIterator last) { return sprout::hash_range(0, first, last); } template inline SPROUT_CONSTEXPR std::size_t hash_range(std::size_t seed, InputRange const& rng) { return sprout::hash_range(seed, sprout::begin(rng), sprout::end(rng)); } template inline SPROUT_CONSTEXPR std::size_t hash_range(InputRange const& rng) { return sprout::hash_range(0, rng); } } // namespace sprout #endif // #ifndef SPROUT_FUNCTIONAL_HASH_HASH_RANGE_HPP