From 507fae612903f5bbd077af89f8b5f8d33f673254 Mon Sep 17 00:00:00 2001 From: subcrip Date: Tue, 18 Jun 2024 15:25:22 +0800 Subject: [PATCH] Update include.hh Signed-off-by: subcrip --- include.hh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include.hh b/include.hh index a804a91..c7b760d 100644 --- a/include.hh +++ b/include.hh @@ -429,6 +429,23 @@ istream& operator>>(istream& in, MLLd& num) { } // miscancellous +template +bool chmax(T& lhs, const U& rhs) { + bool ret = lhs < rhs; + if (ret) { + lhs = rhs; + } + return ret; +} +template +bool chmin(T& lhs, const U& rhs) { + bool ret = lhs > rhs; + if (ret) { + lhs = rhs; + } + return ret; +} + #define functor(func) [&](auto&&... val) \ noexcept(noexcept(func(std::forward(val)...))) -> decltype(auto) \ {return func(std::forward(val)...);}