diff options
| -rw-r--r-- | entity/constraints.hpp | 9 | ||||
| -rw-r--r-- | test/entity.cpp | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/entity/constraints.hpp b/entity/constraints.hpp index f8434bd7..248a8422 100644 --- a/entity/constraints.hpp +++ b/entity/constraints.hpp @@ -11,7 +11,8 @@ namespace floormat::entities::erased_constraints { static_assert(sizeof(std::size_t) == sizeof(std::uintptr_t)); static_assert(sizeof(std::size_t) == sizeof(std::ptrdiff_t)); -struct range final { +struct range final +{ using U = std::size_t; using I = std::make_signed_t<U>; enum type_ : unsigned char { type_none, type_float, type_uint, type_int, }; @@ -61,14 +62,16 @@ struct group final { namespace floormat::entities::constraints { -template<typename T> struct range { +template<typename T> struct range +{ using limits = std::numeric_limits<T>; T min = limits::min(), max = limits::max(); constexpr operator erased_constraints::range() const; }; -template<typename T> constexpr range<T>::operator erased_constraints::range() const +template<typename T> +constexpr range<T>::operator erased_constraints::range() const { using enum erased_constraints::range::type_; if constexpr (std::is_floating_point_v<T>) diff --git a/test/entity.cpp b/test/entity.cpp index e1f221f1..faaa0d41 100644 --- a/test/entity.cpp +++ b/test/entity.cpp @@ -163,7 +163,7 @@ void test_predicate() static_assert(foo.is_enabled(foo.predicate, x) == field_status::hidden); fm_assert(foo.erased().is_enabled(x) == field_status::hidden); constexpr auto foo2 = entity::type<int>::field{"foo"_s, &TestAccessors::foo, &TestAccessors::foo, - [](const TestAccessors&) { return field_status::readonly; }}; + [](const TestAccessors&) { return field_status::readonly; }}; static_assert(foo2.is_enabled(foo2.predicate, x) == field_status::readonly); fm_assert(foo2.erased().is_enabled(x) == field_status::readonly); constexpr auto foo3 = entity::type<int>::field{"foo"_s, &TestAccessors::foo, &TestAccessors::foo}; |
