Skip to content

Commit 87e8b54

Browse files
goldvitalycopybara-github
authored andcommitted
Define combine_weakly_mixed_integer in HashSelect::State in order to allow friend auto AbslHashValue instead of friend H AbslHashValue.
PiperOrigin-RevId: 750259237 Change-Id: Icb1c9427537dbabb55f971d3f8acdeb0be37b42c
1 parent 8dfced2 commit 87e8b54

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

absl/hash/hash_test.cc

+16
Original file line numberDiff line numberDiff line change
@@ -1223,4 +1223,20 @@ TEST(HashOf, MatchesTypeErasedHashState) {
12231223
TypeErasedHashStateUser{1, s}));
12241224
}
12251225

1226+
struct AutoReturnTypeUser {
1227+
int a;
1228+
std::string b;
1229+
1230+
template <typename H>
1231+
friend auto AbslHashValue(H state, const AutoReturnTypeUser& value) {
1232+
return H::combine(std::move(state), value.a, value.b);
1233+
}
1234+
};
1235+
1236+
TEST(HashOf, AutoReturnTypeUser) {
1237+
std::string s = "s";
1238+
EXPECT_EQ(absl::HashOf(1, s),
1239+
absl::Hash<AutoReturnTypeUser>{}(AutoReturnTypeUser{1, s}));
1240+
}
1241+
12261242
} // namespace

absl/hash/internal/hash.h

+2
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,8 @@ struct HashSelect {
988988
size_t);
989989
using State::HashStateBase::combine_contiguous;
990990
static State combine_raw(State state, uint64_t value);
991+
static State combine_weakly_mixed_integer(State hash_state,
992+
WeaklyMixedInteger value);
991993
};
992994

993995
struct UniquelyRepresentedProbe {

0 commit comments

Comments
 (0)