Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-01 08:33:10

0001 /* Hash function characterization.
0002  *
0003  * Copyright 2022-2024 Joaquin M Lopez Munoz.
0004  * Distributed under the Boost Software License, Version 1.0.
0005  * (See accompanying file LICENSE_1_0.txt or copy at
0006  * http://www.boost.org/LICENSE_1_0.txt)
0007  *
0008  * See https://www.boost.org/libs/unordered for library home page.
0009  */
0010 
0011 #ifndef BOOST_UNORDERED_HASH_TRAITS_HPP
0012 #define BOOST_UNORDERED_HASH_TRAITS_HPP
0013 
0014 #include <boost/unordered/detail/type_traits.hpp>
0015 
0016 namespace boost{
0017 namespace unordered{
0018 
0019 namespace detail{
0020 
0021 template<typename Hash,typename=void>
0022 struct hash_is_avalanching_impl:std::false_type{};
0023 
0024 template<typename IsAvalanching>
0025 struct avalanching_value
0026 {
0027   static constexpr bool value=IsAvalanching::value;
0028 };
0029 
0030 /* may be explicitly marked as BOOST_DEPRECATED in the future */
0031 template<> struct avalanching_value<void>
0032 {
0033   static constexpr bool value=true;
0034 };
0035 
0036 template<typename Hash>
0037 struct hash_is_avalanching_impl<
0038   Hash,
0039   boost::unordered::detail::void_t<typename Hash::is_avalanching>
0040 >:std::integral_constant<
0041   bool,
0042   avalanching_value<typename Hash::is_avalanching>::value
0043 >{};
0044 
0045 template<typename Hash>
0046 struct hash_is_avalanching_impl<
0047   Hash,
0048   typename std::enable_if<((void)Hash::is_avalanching,true)>::type
0049 >{}; /* Hash::is_avalanching is not a type: compile error downstream */
0050 
0051 } /* namespace detail */
0052 
0053 /* Each trait can be partially specialized by users for concrete hash functions
0054  * when actual characterization differs from default.
0055  */
0056 
0057 /* hash_is_avalanching<Hash>::value is:
0058  *   - false if Hash::is_avalanching is not present.
0059  *   - Hash::is_avalanching::value if this is present and constexpr-convertible
0060  *     to a bool.
0061  *   - true if Hash::is_avalanching is void (deprecated).
0062  *   - ill-formed otherwise.
0063  */
0064 template<typename Hash>
0065 struct hash_is_avalanching: detail::hash_is_avalanching_impl<Hash>::type{};
0066 
0067 } /* namespace unordered */
0068 } /* namespace boost */
0069 
0070 #endif