mirror of
https://github.com/orange-cpp/omath.git
synced 2026-08-08 05:52:07 +00:00
added template hash
This commit is contained in:
@@ -225,13 +225,14 @@ namespace omath
|
||||
};
|
||||
} // namespace omath
|
||||
|
||||
template<> struct std::hash<omath::Vector4<float>>
|
||||
template<class Type>
|
||||
struct std::hash<omath::Vector4<Type>> // NOLINT(*-dcl58-cpp)
|
||||
{
|
||||
[[nodiscard("You must use hash value")]]
|
||||
std::size_t operator()(const omath::Vector4<float>& vec) const noexcept
|
||||
std::size_t operator()(const omath::Vector4<Type>& vec) const noexcept
|
||||
{
|
||||
std::size_t hash = 0;
|
||||
constexpr std::hash<float> hasher;
|
||||
constexpr std::hash<Type> hasher;
|
||||
|
||||
hash ^= hasher(vec.x) + 0x9e3779b9 + (hash << 6) + (hash >> 2);
|
||||
hash ^= hasher(vec.y) + 0x9e3779b9 + (hash << 6) + (hash >> 2);
|
||||
@@ -240,7 +241,6 @@ template<> struct std::hash<omath::Vector4<float>>
|
||||
return hash;
|
||||
}
|
||||
};
|
||||
|
||||
template<class Type>
|
||||
struct std::formatter<omath::Vector4<Type>> // NOLINT(*-dcl58-cpp)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user