From 5959647826fe8420baf5d591c349deaf61393506 Mon Sep 17 00:00:00 2001 From: "Maarten L. Hekkelman" Date: Mon, 4 Nov 2024 09:25:51 +0100 Subject: [PATCH] three way comparison for point --- include/cif++/point.hpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/include/cif++/point.hpp b/include/cif++/point.hpp index 08949e3..b4e8a6e 100644 --- a/include/cif++/point.hpp +++ b/include/cif++/point.hpp @@ -662,12 +662,23 @@ struct point_type return std::make_tuple(std::ref(m_x), std::ref(m_y), std::ref(m_z)); } - /// \brief Compare with @a rhs +#if defined(__cpp_impl_three_way_comparison) + /// \brief a default spaceship operator + constexpr auto operator<=>(const point_type &rhs) const = default; +#else + /// \brief a default equals operator constexpr bool operator==(const point_type &rhs) const { return m_x == rhs.m_x and m_y == rhs.m_y and m_z == rhs.m_z; } + /// \brief a default not-equals operator + constexpr bool operator!=(const point_type &rhs) const + { + return not operator==(rhs); + } +#endif + // consider point as a vector... perhaps I should rename point? /// \brief looking at the point as if it is a vector, return the squared length