maths: add unary 'max'

This commit is contained in:
Danny Robson 2020-10-20 15:34:27 +10:00
parent 6b46852902
commit 928e2aa2d5

View File

@ -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 <concepts::integral ValueT>
constexpr decltype(auto)
max (ValueT &&val)
{
return std::forward<ValueT> (val);
}
/// Variadic maximum
template <typename T, typename U, typename ...Args>
constexpr std::enable_if_t<