]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/variant/detail/hash_variant.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / variant / detail / hash_variant.hpp
1 //-----------------------------------------------------------------------------
2 // boost variant/detail/hash_variant.hpp header file
3 // See http://www.boost.org for updates, documentation, and revision history.
4 //-----------------------------------------------------------------------------
5 //
6 // Copyright (c) 2011
7 // Antony Polukhin
8 //
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)
12
13
14 #ifndef BOOST_HASH_VARIANT_FUNCTION_HPP
15 #define BOOST_HASH_VARIANT_FUNCTION_HPP
16
17 #if defined(_MSC_VER)
18 # pragma once
19 #endif
20
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>
25
26 namespace boost {
27
28 namespace detail { namespace variant {
29 struct variant_hasher: public boost::static_visitor<std::size_t> {
30 template <class T>
31 std::size_t operator()(T const& val) const {
32 boost::hash<T> hasher;
33 return hasher(val);
34 }
35 };
36 }}
37
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());
42 return seed;
43 }
44 }
45
46 #endif
47