algorithm.hpp 673 B

123456789101112131415161718192021222324252627
  1. #pragma once
  2. #include <nall/traits.hpp>
  3. #undef min
  4. #undef max
  5. namespace nall {
  6. template<typename T, typename U> constexpr auto min(const T& t, const U& u) -> T {
  7. return t < u ? t : (T)u;
  8. }
  9. template<typename T, typename U, typename... P> constexpr auto min(const T& t, const U& u, P&&... p) -> T {
  10. return t < u ? min(t, forward<P>(p)...) : min(u, forward<P>(p)...);
  11. }
  12. template<typename T, typename U> constexpr auto max(const T& t, const U& u) -> T {
  13. return t > u ? t : (T)u;
  14. }
  15. template<typename T, typename U, typename... P> constexpr auto max(const T& t, const U& u, P&&... p) -> T {
  16. return t > u ? max(t, forward<P>(p)...) : max(u, forward<P>(p)...);
  17. }
  18. }