1//-----------------------------------------------------------------------------
2// boost variant/detail/std_hash.hpp header file
3// See http://www.boost.org for updates, documentation, and revision history.
4//-----------------------------------------------------------------------------
5//
6// Copyright (c) 2018-2023 Antony Polukhin
7//
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)
11
12
13#ifndef BOOST_VARIANT_DETAIL_STD_HASH_HPP
14#define BOOST_VARIANT_DETAIL_STD_HASH_HPP
15
16#include <boost/config.hpp>
17#ifdef BOOST_HAS_PRAGMA_ONCE
18# pragma once
19#endif
20
21#include <boost/variant/variant_fwd.hpp>
22#include <boost/variant/detail/hash_variant.hpp>
23
24///////////////////////////////////////////////////////////////////////////////
25// macro BOOST_VARIANT_DO_NOT_SPECIALIZE_STD_HASH
26//
27// Define this macro if you do not wish to have a std::hash specialization for
28// boost::variant.
29
30#if !defined(BOOST_VARIANT_DO_NOT_SPECIALIZE_STD_HASH) && !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
31
32#include <functional> // for std::hash
33
34namespace std {
35 template < BOOST_VARIANT_ENUM_PARAMS(typename T) >
36 struct hash<boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) > > {
37 std::size_t operator()(const boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >& val) const {
38 return ::boost::hash_value(val);
39 }
40 };
41}
42
43#endif // #if !defined(BOOST_VARIANT_DO_NOT_SPECIALIZE_STD_HASH) && !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
44
45#endif // BOOST_VARIANT_DETAIL_STD_HASH_HPP
46
47