add lt gt lte gte restrictions, update unit tests, update documentation

This commit is contained in:
ado
2021-01-03 15:38:07 +01:00
parent cc7e6f7806
commit fdae9b6413
3 changed files with 155 additions and 33 deletions

View File

@@ -52,6 +52,41 @@ public:
}
};
////////////////
// greater than or equal to
// greater than
// less than
// less than or equal to
////////////////
template <typename T, auto N>
struct gt {
bool ss_valid(const T& value) const {
return value > N;
}
};
template <typename T, auto N>
struct gte {
bool ss_valid(const T& value) const {
return value >= N;
}
};
template <typename T, auto N>
struct lt {
bool ss_valid(const T& value) const {
return value < N;
}
};
template <typename T, auto N>
struct lte {
bool ss_valid(const T& value) const {
return value <= N;
}
};
////////////////
// in range
////////////////
@@ -61,10 +96,6 @@ struct ir {
bool ss_valid(const T& value) const {
return value >= Min && value <= Max;
}
const char* error() const {
return "out of range";
}
};
////////////////
@@ -76,10 +107,6 @@ struct oor {
bool ss_valid(const T& value) const {
return value < Min || value > Max;
}
const char* error() const {
return "in restricted range";
}
};
////////////////