Skip to content

Commit

Permalink
enable hashing of std::vector<bool>
Browse files Browse the repository at this point in the history
it's iterable but there's no hash function
for the wrapper type
but there's `std::hash<std::vector<bool>>`
so we use it
  • Loading branch information
felixguendling committed Aug 26, 2024
1 parent f5c8baf commit b27c021
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/cista/hashing.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ struct hashing {
: hash(std::string_view{&(*begin(el)), el.size()}, seed);
} else if constexpr (std::is_scalar_v<Type>) {
return hash_combine(seed, el);
} else if constexpr (has_std_hash_v<Type>) {
return hash_combine(std::hash<Type>()(el), seed);
} else if constexpr (is_iterable_v<Type>) {
auto h = seed;
for (auto const& v : el) {
Expand All @@ -114,8 +116,6 @@ struct hashing {
return h;
} else if constexpr (is_strong_v<Type>) {
return hashing<typename Type::value_t>{}(el.v_, seed);
} else if constexpr (has_std_hash_v<Type>) {
return hash_combine(std::hash<Type>()(el), seed);
} else {
static_assert(has_hash_v<Type> || std::is_scalar_v<Type> ||
has_std_hash_v<Type> || is_iterable_v<Type> ||
Expand Down

0 comments on commit b27c021

Please sign in to comment.