File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -1195,4 +1195,22 @@ TEST(HashOf, CantPassExplicitTemplateParameters) {
11951195 EXPECT_FALSE (HashOfExplicitParameter<int >(0 ));
11961196}
11971197
1198+ struct TypeErasedHashStateUser {
1199+ int a;
1200+ std::string b;
1201+
1202+ template <typename H>
1203+ friend H AbslHashValue (H state, const TypeErasedHashStateUser& value) {
1204+ absl::HashState type_erased_state = absl::HashState::Create (&state);
1205+ absl::HashState::combine (std::move (type_erased_state), value.a , value.b );
1206+ return state;
1207+ }
1208+ };
1209+
1210+ TEST (HashOf, MatchesTypeErasedHashState) {
1211+ std::string s = " s" ;
1212+ EXPECT_EQ (absl::HashOf (1 , s), absl::Hash<TypeErasedHashStateUser>{}(
1213+ TypeErasedHashStateUser{1 , s}));
1214+ }
1215+
11981216} // namespace
You can’t perform that action at this time.
0 commit comments