File indexing completed on 2025-01-18 09:53:32
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef BOOST_HASH_VARIANT_FUNCTION_HPP
0014 #define BOOST_HASH_VARIANT_FUNCTION_HPP
0015
0016 #if defined(_MSC_VER)
0017 # pragma once
0018 #endif
0019
0020 #include <boost/variant/variant_fwd.hpp>
0021 #include <boost/variant/static_visitor.hpp>
0022 #include <boost/variant/apply_visitor.hpp>
0023 #include <boost/functional/hash_fwd.hpp>
0024
0025 namespace boost {
0026
0027 namespace detail { namespace variant {
0028 struct variant_hasher: public boost::static_visitor<std::size_t> {
0029 template <class T>
0030 std::size_t operator()(T const& val) const {
0031 boost::hash<T> hasher;
0032 return hasher(val);
0033 }
0034 };
0035 }}
0036
0037 template < BOOST_VARIANT_ENUM_PARAMS(typename T) >
0038 std::size_t hash_value(variant< BOOST_VARIANT_ENUM_PARAMS(T) > const& val) {
0039 std::size_t seed = boost::apply_visitor(detail::variant::variant_hasher(), val);
0040 hash_combine(seed, val.which());
0041 return seed;
0042 }
0043 }
0044
0045 #endif
0046