#define DEPTH_H
#include "ue2common.h"
+#include "util/operators.h"
#ifdef DUMP_SUPPORT
#include <string>
* \brief Type used to represent depth information; value is either a count,
* or the special values "infinity" and "unreachable".
*/
-class depth {
+class depth : totally_ordered<depth> {
public:
/** \brief The default depth is special value "unreachable". */
depth() = default;
}
bool operator<(const depth &d) const { return val < d.val; }
- bool operator>(const depth &d) const { return val > d.val; }
- bool operator<=(const depth &d) const { return val <= d.val; }
- bool operator>=(const depth &d) const { return val >= d.val; }
bool operator==(const depth &d) const { return val == d.val; }
- bool operator!=(const depth &d) const { return val != d.val; }
// The following comparison operators exist for use against integer types
// that are bigger than what we can safely convert to depth (such as those
/**
* \brief Encapsulates a min/max pair.
*/
-struct DepthMinMax {
- depth min;
- depth max;
+struct DepthMinMax : totally_ordered<DepthMinMax> {
+ depth min{depth::infinity()};
+ depth max{0};
- DepthMinMax() : min(depth::infinity()), max(depth(0)) {}
+ DepthMinMax() = default;
DepthMinMax(const depth &mn, const depth &mx) : min(mn), max(mx) {}
bool operator<(const DepthMinMax &b) const {
return min == b.min && max == b.max;
}
- bool operator!=(const DepthMinMax &b) const {
- return !(*this == b);
- }
-
#ifdef DUMP_SUPPORT
/** \brief Render as a string, useful for debugging. */
std::string str() const;