1 /*============================================================================= 2 Copyright (c) 2014 Christoph Weiss 3 4 Distributed under the Boost Software License, Version 1.0. (See accompanying 5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 ==============================================================================*/ 7 #if !defined(FUSION_HASH_23072014_1017) 8 #define FUSION_HASH_23072014_1017 9 10 #include <boost/functional/hash.hpp> 11 #include <boost/fusion/algorithm/iteration/fold.hpp> 12 #include <boost/fusion/support/is_sequence.hpp> 13 #include <boost/utility/enable_if.hpp> 14 15 namespace boost { namespace fusion 16 { 17 namespace hashing 18 { 19 struct hash_combine_fold 20 { 21 typedef std::size_t result_type; 22 template<typename T> operator ()boost::fusion::hashing::hash_combine_fold23 inline std::size_t operator()(std::size_t seed, T const& v) 24 { 25 boost::hash_combine(seed, v); 26 return seed; 27 } 28 }; 29 30 template <typename Seq> 31 inline typename 32 boost::enable_if<traits::is_sequence<Seq>, std::size_t>::type hash_value(Seq const & seq)33 hash_value(Seq const& seq) 34 { 35 return fold(seq, 0, hash_combine_fold()); 36 } 37 } 38 39 using hashing::hash_value; 40 }} 41 42 #endif 43