#pragma once #include "erased-constraints.hpp" #include #include #include #include namespace floormat::entities::constraints { template struct range { using limits = std::numeric_limits; T min = limits::min(), max = limits::max(); constexpr operator erased_constraints::range() const noexcept; constexpr operator std::pair() const noexcept; constexpr bool operator==(const range&) const noexcept = default; }; template range(T min, T max) -> range; template constexpr range::operator erased_constraints::range() const noexcept { using enum erased_constraints::range::type_; if constexpr (std::is_floating_point_v) return { { .f = min }, { .f = max }, type_float }; if constexpr (std::is_integral_v && std::is_unsigned_v) return { {.u = min}, {.u = max}, type_uint }; if constexpr (std::is_integral_v && std::is_signed_v) return { {.i = min}, {.i = max}, type_int }; return { {}, {}, type_none }; } template constexpr range::operator std::pair() const noexcept { return { min, max }; } template<> struct range { constexpr operator erased_constraints::range() const noexcept { return {}; } }; using max_length = erased_constraints::max_length; } // namespace floormat::entities::constraints