From 928e2aa2d586c43bb4c3bd941d075d42b5230380 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 20 Oct 2020 15:34:27 +1000 Subject: [PATCH] maths: add unary 'max' --- maths.hpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/maths.hpp b/maths.hpp index 93eda14f..77b3513d 100644 --- a/maths.hpp +++ b/maths.hpp @@ -573,7 +573,19 @@ namespace cruft { } - //------------------------------------------------------------------------- + ///------------------------------------------------------------------------ + /// Unary maximum provided to simplify application of max to template + /// parameter packs. + /// + /// eg, `max (sizeof (T)...)` will otherwise fail with a single type. + template + constexpr decltype(auto) + max (ValueT &&val) + { + return std::forward (val); + } + + /// Variadic maximum template constexpr std::enable_if_t<