diff --git a/deps/ox/src/ox/std/concepts.hpp b/deps/ox/src/ox/std/concepts.hpp index fb5c358f..d4667963 100644 --- a/deps/ox/src/ox/std/concepts.hpp +++ b/deps/ox/src/ox/std/concepts.hpp @@ -16,6 +16,10 @@ template concept CommonPtrWith = ox::is_same_v::type, typename ox::remove_pointer::type>; +template +concept CommonRefWith = ox::is_same_v, + typename ox::remove_reference_t>; + template concept same_as = ox::is_same_v; @@ -50,4 +54,4 @@ constexpr auto isOxString(const StringView*) noexcept { template concept OxString_c = detail::isOxString(static_cast(nullptr)); -} \ No newline at end of file +} diff --git a/deps/ox/src/ox/std/math.hpp b/deps/ox/src/ox/std/math.hpp index 28f77ec7..be158407 100644 --- a/deps/ox/src/ox/std/math.hpp +++ b/deps/ox/src/ox/std/math.hpp @@ -14,19 +14,37 @@ namespace ox { template [[nodiscard]] -constexpr const T &min(const T &a, const T &b) noexcept { +constexpr T min(T a, T b) noexcept requires(ox::is_integral_v) { return a < b ? a : b; } template [[nodiscard]] -constexpr const T &max(const T &a, const T &b) noexcept { +constexpr const T &min(const T &a, const T &b) noexcept requires(!ox::is_integral_v) { + return a < b ? a : b; +} + +template +[[nodiscard]] +constexpr T max(T a, T b) noexcept requires(ox::is_integral_v) { return a > b ? a : b; } template [[nodiscard]] -constexpr const T &clamp(const T &v, const T &lo, const T &hi) noexcept { +constexpr const T &max(const T &a, const T &b) noexcept requires(!ox::is_integral_v) { + return a > b ? a : b; +} + +template +[[nodiscard]] +constexpr T clamp(T v, T lo, T hi) noexcept requires(ox::is_integral_v) { + return min(ox::max(v, lo), hi); +} + +template +[[nodiscard]] +constexpr const T &clamp(const T &v, const T &lo, const T &hi) noexcept requires(!ox::is_integral_v) { return min(ox::max(v, lo), hi); }