diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-19 17:47:47 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-19 17:47:47 +0100 |
commit | b7b0195841a22f5b8801c69fa8d61c8b0a07ab06 (patch) | |
tree | 06c1c4a04f4ef6c9c21b9f7cdd0178125846c332 /entity/erased-constraints.hpp | |
parent | 7e2d1599378814a0eb0e5db8db57b379d284438b (diff) |
entity: add the rest of erased accessors
Diffstat (limited to 'entity/erased-constraints.hpp')
-rw-r--r-- | entity/erased-constraints.hpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/entity/erased-constraints.hpp b/entity/erased-constraints.hpp index f462472a..2d4b47ae 100644 --- a/entity/erased-constraints.hpp +++ b/entity/erased-constraints.hpp @@ -50,9 +50,27 @@ template<typename T> constexpr std::pair<T, T> range::convert() const } } -struct length final { +constexpr bool operator==(const range& a, const range& b) +{ + if (a.type != b.type) + return false; + + static constexpr float eps = 1e-6f; + + switch (a.type) + { + default: return false; + case range::type_none: return true; + case range::type_float: return std::fabs(a.min.f - b.min.f) < eps && std::fabs(a.max.f - b.max.f) < eps; + case range::type_uint: return a.min.u == b.min.u && a.max.u == b.max.u; + case range::type_int: return a.min.i == b.min.i && a.max.i == b.max.i; + } +} + +struct max_length final { std::size_t value = std::numeric_limits<std::size_t>::max(); constexpr operator std::size_t() const { return value; } + //constexpr bool operator==(const max_length&) const noexcept = default; }; struct group final { @@ -60,6 +78,7 @@ struct group final { constexpr operator StringView() const { return group_name; } constexpr group() = default; constexpr group(StringView name) : group_name{name} {} + //constexpr bool operator==(const group&) const noexcept = default; }; } // namespace floormat::entities::erased_constraints |