Skip to content

Commit 5959647

Browse files
committed
three way comparison for point
1 parent 9542e21 commit 5959647

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

include/cif++/point.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,12 +662,23 @@ struct point_type
662662
return std::make_tuple(std::ref(m_x), std::ref(m_y), std::ref(m_z));
663663
}
664664

665-
/// \brief Compare with @a rhs
665+
#if defined(__cpp_impl_three_way_comparison)
666+
/// \brief a default spaceship operator
667+
constexpr auto operator<=>(const point_type &rhs) const = default;
668+
#else
669+
/// \brief a default equals operator
666670
constexpr bool operator==(const point_type &rhs) const
667671
{
668672
return m_x == rhs.m_x and m_y == rhs.m_y and m_z == rhs.m_z;
669673
}
670674

675+
/// \brief a default not-equals operator
676+
constexpr bool operator!=(const point_type &rhs) const
677+
{
678+
return not operator==(rhs);
679+
}
680+
#endif
681+
671682
// consider point as a vector... perhaps I should rename point?
672683

673684
/// \brief looking at the point as if it is a vector, return the squared length

0 commit comments

Comments
 (0)