maths: add unary 'max'
This commit is contained in:
parent
6b46852902
commit
928e2aa2d5
14
maths.hpp
14
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 <concepts::integral ValueT>
|
||||||
|
constexpr decltype(auto)
|
||||||
|
max (ValueT &&val)
|
||||||
|
{
|
||||||
|
return std::forward<ValueT> (val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Variadic maximum
|
/// Variadic maximum
|
||||||
template <typename T, typename U, typename ...Args>
|
template <typename T, typename U, typename ...Args>
|
||||||
constexpr std::enable_if_t<
|
constexpr std::enable_if_t<
|
||||||
|
Loading…
Reference in New Issue
Block a user