hash_is_avalanching.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright 2025 Joaquin M Lopez Munoz.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // https://www.boost.org/LICENSE_1_0.txt
  4. #ifndef BOOST_HASH_HASH_IS_AVALANCHING_HPP_INCLUDED
  5. #define BOOST_HASH_HASH_IS_AVALANCHING_HPP_INCLUDED
  6. #include <type_traits>
  7. namespace boost
  8. {
  9. namespace hash_detail
  10. {
  11. template<class... Ts> struct make_void
  12. {
  13. using type = void;
  14. };
  15. template<class... Ts> using void_t = typename make_void<Ts...>::type;
  16. template<class IsAvalanching> struct avalanching_value
  17. {
  18. static constexpr bool value = IsAvalanching::value;
  19. };
  20. // may be explicitly marked as BOOST_DEPRECATED in the future
  21. template<> struct avalanching_value<void>
  22. {
  23. static constexpr bool value = true;
  24. };
  25. template<class Hash, class = void> struct hash_is_avalanching_impl: std::false_type
  26. {
  27. };
  28. template<class Hash> struct hash_is_avalanching_impl<Hash, void_t<typename Hash::is_avalanching> >:
  29. std::integral_constant<bool, avalanching_value<typename Hash::is_avalanching>::value>
  30. {
  31. };
  32. template<class Hash>
  33. struct hash_is_avalanching_impl<Hash, typename std::enable_if< ((void)Hash::is_avalanching, true) >::type>
  34. {
  35. // Hash::is_avalanching is not a type: we don't define value to produce
  36. // a compile error downstream
  37. };
  38. } // namespace hash_detail
  39. template<class Hash> struct hash_is_avalanching: hash_detail::hash_is_avalanching_impl<Hash>::type
  40. {
  41. };
  42. } // namespace boost
  43. #endif // #ifndef BOOST_HASH_HASH_IS_AVALANCHING_HPP_INCLUDED