also, you can often centralize comparison by encapsulating it into a single function, eg:
Code:
int
compare( Coord const & lhs, Coord const & rhs )
{
/*
if lhs is less than rhs return -1, else if rhs is less than lhs return 1, else return 0
*/
}
inline
bool
operator < ( Coord const & lhs, Coord const & rhs )
{
return compare( lhs, rhs ) < 0;
}
inline
bool
operator <= ( Coord const & lhs, Coord const & rhs )
{
return compare( lhs, rhs ) <= 0;
}
inline
bool
operator == ( Coord const & lhs, Coord const & rhs )
{
return compare( lhs, rhs ) == 0;
}
inline
bool
operator != ( Coord const & lhs, Coord const & rhs )
{
return compare( lhs, rhs ) != 0;
}
inline
bool
operator > ( Coord const & lhs, Coord const & rhs )
{
return compare( lhs, rhs ) > 0;
}
inline
bool
operator >= ( Coord const & lhs, Coord const & rhs )
{
return compare( lhs, rhs ) >= 0;
}