SHARE
TWEET

Untitled

a guest Feb 26th, 2020 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. template <typename Outer>
  2. std::size_t hash_value(const Outer& t) {
  3.   return accumulate<std::size_t>(t, [&](const auto& value, std::size_t hash) {
  4.     using T = std::decay_t<decltype(value)>;
  5.     if constexpr(std::is_arithmetic_v<T> || std::is_enum_v<T>) {
  6.       return details::hash_combine(hash, std::hash<T>{}(value));
  7.     } else if constexpr(details::is_optional_v<T> || details::is_pointer_v<T>) {
  8.       return details::hash_combine(hash, value ? 1 : 0);
  9.     } else if constexpr(details::is_variant_v<T>) {
  10.       return details::hash_combine(hash, value.index());
  11.     } else if constexpr(details::is_range_v<T>) {
  12.       return details::hash_combine(hash, value.size());
  13.     } else {
  14.         return hash;
  15.     }
  16.   });
  17. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top