1 //-----------------------------------------------------------------------------
2 // boost variant/detail/std_hash.hpp header file
3 // See http://www.boost.org for updates, documentation, and revision history.
4 //-----------------------------------------------------------------------------
6 // Copyright (c) 2018-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_VARIANT_DETAIL_STD_HASH_HPP
14 #define BOOST_VARIANT_DETAIL_STD_HASH_HPP
16 #include <boost/config.hpp>
17 #ifdef BOOST_HAS_PRAGMA_ONCE
21 #include <boost/variant/variant_fwd.hpp>
22 #include <boost/variant/detail/hash_variant.hpp>
24 ///////////////////////////////////////////////////////////////////////////////
25 // macro BOOST_VARIANT_DO_NOT_SPECIALIZE_STD_HASH
27 // Define this macro if you do not with to have a std::hash specialization for
30 #if !defined(BOOST_VARIANT_DO_NOT_SPECIALIZE_STD_HASH) && !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
32 #include <functional> // for std::hash
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);
43 #endif // #if !defined(BOOST_VARIANT_DO_NOT_SPECIALIZE_STD_HASH) && !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
45 #endif // BOOST_VARIANT_DETAIL_STD_HASH_HPP