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