Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:23

0001 // Copyright 2005-2009 Daniel James.
0002 // Copyright 2021 Peter Dimov.
0003 // Distributed under the Boost Software License, Version 1.0.
0004 // https://www.boost.org/LICENSE_1_0.txt
0005 
0006 #ifndef BOOST_HASH_DETAIL_HASH_TUPLE_LIKE_HPP
0007 #define BOOST_HASH_DETAIL_HASH_TUPLE_LIKE_HPP
0008 
0009 #include <boost/container_hash/hash_fwd.hpp>
0010 #include <boost/container_hash/is_tuple_like.hpp>
0011 #include <boost/container_hash/is_range.hpp>
0012 #include <type_traits>
0013 #include <utility>
0014 
0015 namespace boost
0016 {
0017 namespace hash_detail
0018 {
0019 
0020 template <std::size_t I, typename T>
0021 inline
0022 typename std::enable_if<(I == std::tuple_size<T>::value), void>::type
0023     hash_combine_tuple_like( std::size_t&, T const& )
0024 {
0025 }
0026 
0027 template <std::size_t I, typename T>
0028 inline
0029 typename std::enable_if<(I < std::tuple_size<T>::value), void>::type
0030     hash_combine_tuple_like( std::size_t& seed, T const& v )
0031 {
0032     using std::get;
0033     boost::hash_combine( seed, get<I>( v ) );
0034 
0035     boost::hash_detail::hash_combine_tuple_like<I + 1>( seed, v );
0036 }
0037 
0038 template <typename T>
0039 inline std::size_t hash_tuple_like( T const& v )
0040 {
0041     std::size_t seed = 0;
0042 
0043     boost::hash_detail::hash_combine_tuple_like<0>( seed, v );
0044 
0045     return seed;
0046 }
0047 
0048 } // namespace hash_detail
0049 
0050 template <class T>
0051 inline
0052 typename std::enable_if<
0053     container_hash::is_tuple_like<T>::value && !container_hash::is_range<T>::value,
0054 std::size_t>::type
0055     hash_value( T const& v )
0056 {
0057     return boost::hash_detail::hash_tuple_like( v );
0058 }
0059 
0060 } // namespace boost
0061 
0062 #endif // #ifndef BOOST_HASH_DETAIL_HASH_TUPLE_LIKE_HPP