memgraph/include/utils/total_ordering.hpp

26 lines
491 B
C++
Raw Normal View History

2015-11-21 20:57:15 +08:00
#pragma once
template <class Derived, class Other = Derived>
struct TotalOrdering
{
friend constexpr bool operator!=(const Derived &a, const Other &b)
{
return !(a == b);
}
2015-11-21 20:57:15 +08:00
friend constexpr bool operator<=(const Derived &a, const Other &b)
{
return a < b || a == b;
}
friend constexpr bool operator>(const Derived &a, const Other &b)
{
return !(a <= b);
}
2015-11-21 20:57:15 +08:00
friend constexpr bool operator>=(const Derived &a, const Other &b)
{
return !(a < b);
}
2015-11-21 20:57:15 +08:00
};