Skip to content

Commit

Permalink
add: MinMax
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo314 committed Jan 15, 2025
1 parent f1c7fcb commit b168206
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cpp/more_functional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ template <typename S>
struct Min {
const S operator()(const S& a, const S& b) const { return std::min(a, b); }
};
template <typename S>
struct MinMax {
const std::pair<S, S> operator()(const std::pair<S, S>& a, const std::pair<S, S>& b) const { return {std::min(a.first, b.first), std::max(a.second, b.second)}; }
};
template <typename S, std::enable_if_t<std::is_integral_v<S>>* = nullptr>
struct Gcd {
constexpr S operator()(const S& a, const S& b) const { return std::gcd(a, b); }
Expand All @@ -42,6 +46,10 @@ template <typename S, std::enable_if_t<std::is_scalar_v<S>>* = nullptr>
struct MinLimit {
constexpr S operator()() const { return std::numeric_limits<S>::lowest(); }
};
template <typename S, std::enable_if_t<std::is_scalar_v<S>>* = nullptr>
struct MaxMinLimit {
constexpr std::pair<S, S> operator()() const { return {std::numeric_limits<S>::max(), std::numeric_limits<S>::lowest()}; }
};
template <typename S>
struct Div {
S operator()(const S& a) const { return S(1) / a; }
Expand Down

0 comments on commit b168206

Please sign in to comment.