Skip to content

Commit d36a990

Browse files
rprichardGerrit Code Review
authored andcommitted
Merge "libmath: use TVECHELPERS_STD_HASH macro for std::hash" into main
2 parents 187efe1 + bb01a64 commit d36a990

8 files changed

Lines changed: 21 additions & 12 deletions

File tree

libs/math/include/math/TVecHelpers.h

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -620,15 +620,10 @@ class TVecDebug {
620620
} // namespace details
621621
} // namespace android
622622

623-
namespace std {
624-
template<template<typename T> class VECTOR, typename T>
625-
struct hash<VECTOR<T>> {
626-
static constexpr bool IS_VECTOR =
627-
std::is_base_of<android::details::TVecUnaryOperators<VECTOR, T>, VECTOR<T>>::value;
628-
629-
typename std::enable_if<IS_VECTOR, size_t>::type
630-
operator()(const VECTOR<T>& v) const {
631-
return v.hash();
632-
}
633-
};
634-
}
623+
#define TVECHELPERS_STD_HASH(VECTOR) \
624+
template <typename T> \
625+
struct std::hash<VECTOR<T>> { \
626+
size_t operator()(const VECTOR<T>& v) const { \
627+
return v.hash(); \
628+
} \
629+
}

libs/math/include/math/mat2.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,5 +373,7 @@ typedef details::TMat22<float> mat2f;
373373
// ----------------------------------------------------------------------------------------
374374
} // namespace android
375375

376+
TVECHELPERS_STD_HASH(android::details::TMat22);
377+
376378
#undef PURE
377379
#undef CONSTEXPR

libs/math/include/math/mat3.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,5 +436,7 @@ typedef details::TMat33<float> mat3f;
436436
// ----------------------------------------------------------------------------------------
437437
} // namespace android
438438

439+
TVECHELPERS_STD_HASH(android::details::TMat33);
440+
439441
#undef PURE
440442
#undef CONSTEXPR

libs/math/include/math/mat4.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,5 +590,7 @@ typedef details::TMat44<float> mat4f;
590590
// ----------------------------------------------------------------------------------------
591591
} // namespace android
592592

593+
TVECHELPERS_STD_HASH(android::details::TMat44);
594+
593595
#undef PURE
594596
#undef CONSTEXPR

libs/math/include/math/quat.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ constexpr inline quatd operator"" _kd(unsigned long long v) { // NOLINT
187187
// ----------------------------------------------------------------------------------------
188188
} // namespace android
189189

190+
TVECHELPERS_STD_HASH(android::details::TQuaternion);
191+
190192
#pragma clang diagnostic pop
191193

192194
#undef PURE

libs/math/include/math/vec2.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,6 @@ typedef details::TVec2<bool> bool2;
122122
// ----------------------------------------------------------------------------------------
123123
} // namespace android
124124

125+
TVECHELPERS_STD_HASH(android::details::TVec2);
126+
125127
#pragma clang diagnostic pop

libs/math/include/math/vec3.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,6 @@ typedef details::TVec3<bool> bool3;
128128
// ----------------------------------------------------------------------------------------
129129
} // namespace android
130130

131+
TVECHELPERS_STD_HASH(android::details::TVec3);
132+
131133
#pragma clang diagnostic pop

libs/math/include/math/vec4.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,6 @@ typedef details::TVec4<bool> bool4;
125125
// ----------------------------------------------------------------------------------------
126126
} // namespace android
127127

128+
TVECHELPERS_STD_HASH(android::details::TVec4);
129+
128130
#pragma clang diagnostic pop

0 commit comments

Comments
 (0)