Skip to content

Commit

Permalink
three way comparison for point
Browse files Browse the repository at this point in the history
  • Loading branch information
mhekkel committed Nov 4, 2024
1 parent 9542e21 commit 5959647
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion include/cif++/point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5959647

Please sign in to comment.