@@ -159,9 +159,9 @@ namespace omath
159159 return Vector2<Type>::length ();
160160 }
161161
162- [[nodiscard]] Type distance_to (const Vector3& vOther ) const noexcept
162+ [[nodiscard]] Type distance_to (const Vector3& v_other ) const noexcept
163163 {
164- return (*this - vOther ).length ();
164+ return (*this - v_other ).length ();
165165 }
166166#endif
167167
@@ -279,21 +279,33 @@ namespace omath
279279 }
280280 };
281281} // namespace omath
282- // ReSharper disable once CppRedundantNamespaceDefinition
283- namespace std
282+
283+ template <> struct std ::hash<omath::Vector3< float >>
284284{
285- template <> struct hash < omath::Vector3<float >>
285+ std:: size_t operator ()( const omath::Vector3<float >& vec) const noexcept
286286 {
287- std::size_t operator ()(const omath::Vector3<float >& vec) const noexcept
288- {
289- std::size_t hash = 0 ;
290- constexpr std::hash<float > hasher;
287+ std::size_t hash = 0 ;
288+ constexpr std::hash<float > hasher;
291289
292- hash ^= hasher (vec.x ) + 0x9e3779b9 + (hash << 6 ) + (hash >> 2 );
293- hash ^= hasher (vec.y ) + 0x9e3779b9 + (hash << 6 ) + (hash >> 2 );
294- hash ^= hasher (vec.z ) + 0x9e3779b9 + (hash << 6 ) + (hash >> 2 );
290+ hash ^= hasher (vec.x ) + 0x9e3779b9 + (hash << 6 ) + (hash >> 2 );
291+ hash ^= hasher (vec.y ) + 0x9e3779b9 + (hash << 6 ) + (hash >> 2 );
292+ hash ^= hasher (vec.z ) + 0x9e3779b9 + (hash << 6 ) + (hash >> 2 );
295293
296- return hash;
297- }
298- };
299- } // namespace std
294+ return hash;
295+ }
296+ };
297+
298+ template <class Type >
299+ struct std ::formatter<omath::Vector3<Type>> // NOLINT(*-dcl58-cpp)
300+ {
301+ [[nodiscard]]
302+ static constexpr auto parse (std::format_parse_context& ctx)
303+ {
304+ return ctx.begin ();
305+ }
306+ [[nodiscard]]
307+ static auto format (const omath::Vector3<Type>& vec, std::format_context& ctx)
308+ {
309+ return std::format_to (ctx.out (), " [{}, {}, {}]" , vec.x , vec.y , vec.z );
310+ }
311+ };
0 commit comments