From ced76721ac0f3893a55fb99dbf6aec34ac11ee1b Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Mon, 23 Apr 2018 15:40:24 +1000 Subject: [PATCH] maths: add array max/min convenience functions --- maths.hpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/maths.hpp b/maths.hpp index 4562d655..e2520728 100644 --- a/maths.hpp +++ b/maths.hpp @@ -676,6 +676,34 @@ namespace util { } + //------------------------------------------------------------------------- + template + const ValueT& + max (const std::array &vals) + { + return *std::max_element (vals.begin (), vals.end ()); + } + + + template + ValueT& + max (std::array &&) = delete; + + + //------------------------------------------------------------------------- + template + const ValueT& + min (const std::array &vals) + { + return *std::min_element (vals.begin (), vals.end ()); + } + + + template + ValueT& + min (std::array &&) = delete; + + /////////////////////////////////////////////////////////////////////////// // Limiting functions