1 //-----------------------------------------------------------------------------
2 // boost variant/detail/hash_variant.hpp header file
3 // See http://www.boost.org for updates, documentation, and revision history.
4 //-----------------------------------------------------------------------------
9 // Distributed under the Boost Software License, Version 1.0. (See
10 // accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt)
14 #ifndef BOOST_HASH_VARIANT_FUNCTION_HPP
15 #define BOOST_HASH_VARIANT_FUNCTION_HPP
21 #include <boost/variant/variant_fwd.hpp>
22 #include <boost/variant/static_visitor.hpp>
23 #include <boost/variant/apply_visitor.hpp>
24 #include <boost/functional/hash_fwd.hpp>
28 namespace detail { namespace variant {
29 struct variant_hasher: public boost::static_visitor<std::size_t> {
31 std::size_t operator()(T const& val) const {
32 boost::hash<T> hasher;
38 template < BOOST_VARIANT_ENUM_PARAMS(typename T) >
39 std::size_t hash_value(variant< BOOST_VARIANT_ENUM_PARAMS(T) > const& val) {
40 std::size_t seed = boost::apply_visitor(detail::variant::variant_hasher(), val);
41 hash_combine(seed, val.which());