Add --gen-absl-hash option to generate AbslHashValue for structs. (#8868)

This commit is contained in:
Derek Bailey
2025-12-19 11:49:50 -08:00
committed by GitHub
parent fb55e0c9de
commit 8cb53ccc95
15 changed files with 186 additions and 3 deletions

View File

@@ -712,6 +712,10 @@ inline bool operator!=(const Test &lhs, const Test &rhs) {
return !(lhs == rhs);
}
template <typename H>
inline H AbslHashValue(H h, const Test &obj) {
return H::combine(std::move(h), obj.a(), obj.b());
}
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Vec3 FLATBUFFERS_FINAL_CLASS {
private:
@@ -810,6 +814,10 @@ inline bool operator!=(const Vec3 &lhs, const Vec3 &rhs) {
return !(lhs == rhs);
}
template <typename H>
inline H AbslHashValue(H h, const Vec3 &obj) {
return H::combine(std::move(h), obj.x(), obj.y(), obj.z(), obj.test1(), obj.test2(), obj.test3());
}
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Ability FLATBUFFERS_FINAL_CLASS {
private:
@@ -859,6 +867,10 @@ inline bool operator!=(const Ability &lhs, const Ability &rhs) {
return !(lhs == rhs);
}
template <typename H>
inline H AbslHashValue(H h, const Ability &obj) {
return H::combine(std::move(h), obj.id(), obj.distance());
}
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) StructOfStructs FLATBUFFERS_FINAL_CLASS {
private:
@@ -912,6 +924,10 @@ inline bool operator!=(const StructOfStructs &lhs, const StructOfStructs &rhs) {
return !(lhs == rhs);
}
template <typename H>
inline H AbslHashValue(H h, const StructOfStructs &obj) {
return H::combine(std::move(h), obj.a(), obj.b(), obj.c());
}
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) StructOfStructsOfStructs FLATBUFFERS_FINAL_CLASS {
private:
@@ -945,6 +961,10 @@ inline bool operator!=(const StructOfStructsOfStructs &lhs, const StructOfStruct
return !(lhs == rhs);
}
template <typename H>
inline H AbslHashValue(H h, const StructOfStructsOfStructs &obj) {
return H::combine(std::move(h), obj.a());
}
} // namespace Example