mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
depth: use totally_ordered
This commit is contained in:
parent
cf82924a39
commit
5d1922327e
@ -34,6 +34,7 @@
|
|||||||
#define DEPTH_H
|
#define DEPTH_H
|
||||||
|
|
||||||
#include "ue2common.h"
|
#include "ue2common.h"
|
||||||
|
#include "util/operators.h"
|
||||||
|
|
||||||
#ifdef DUMP_SUPPORT
|
#ifdef DUMP_SUPPORT
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -52,7 +53,7 @@ struct DepthOverflowError {};
|
|||||||
* \brief Type used to represent depth information; value is either a count,
|
* \brief Type used to represent depth information; value is either a count,
|
||||||
* or the special values "infinity" and "unreachable".
|
* or the special values "infinity" and "unreachable".
|
||||||
*/
|
*/
|
||||||
class depth {
|
class depth : totally_ordered<depth> {
|
||||||
public:
|
public:
|
||||||
/** \brief The default depth is special value "unreachable". */
|
/** \brief The default depth is special value "unreachable". */
|
||||||
depth() = default;
|
depth() = default;
|
||||||
@ -93,11 +94,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
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; }
|
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
|
// The following comparison operators exist for use against integer types
|
||||||
// that are bigger than what we can safely convert to depth (such as those
|
// that are bigger than what we can safely convert to depth (such as those
|
||||||
@ -239,11 +236,11 @@ private:
|
|||||||
/**
|
/**
|
||||||
* \brief Encapsulates a min/max pair.
|
* \brief Encapsulates a min/max pair.
|
||||||
*/
|
*/
|
||||||
struct DepthMinMax {
|
struct DepthMinMax : totally_ordered<DepthMinMax> {
|
||||||
depth min;
|
depth min{depth::infinity()};
|
||||||
depth max;
|
depth max{0};
|
||||||
|
|
||||||
DepthMinMax() : min(depth::infinity()), max(depth(0)) {}
|
DepthMinMax() = default;
|
||||||
DepthMinMax(const depth &mn, const depth &mx) : min(mn), max(mx) {}
|
DepthMinMax(const depth &mn, const depth &mx) : min(mn), max(mx) {}
|
||||||
|
|
||||||
bool operator<(const DepthMinMax &b) const {
|
bool operator<(const DepthMinMax &b) const {
|
||||||
@ -257,10 +254,6 @@ struct DepthMinMax {
|
|||||||
return min == b.min && max == b.max;
|
return min == b.min && max == b.max;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(const DepthMinMax &b) const {
|
|
||||||
return !(*this == b);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DUMP_SUPPORT
|
#ifdef DUMP_SUPPORT
|
||||||
/** \brief Render as a string, useful for debugging. */
|
/** \brief Render as a string, useful for debugging. */
|
||||||
std::string str() const;
|
std::string str() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user