maths: add array max/min convenience functions

This commit is contained in:
Danny Robson 2018-04-23 15:40:24 +10:00
parent 90244c5347
commit ced76721ac

View File

@ -676,6 +676,34 @@ namespace util {
} }
//-------------------------------------------------------------------------
template <typename ValueT, size_t CountV>
const ValueT&
max (const std::array<ValueT,CountV> &vals)
{
return *std::max_element (vals.begin (), vals.end ());
}
template <typename ValueT, size_t CountV>
ValueT&
max (std::array<ValueT,CountV> &&) = delete;
//-------------------------------------------------------------------------
template <typename ValueT, size_t CountV>
const ValueT&
min (const std::array<ValueT,CountV> &vals)
{
return *std::min_element (vals.begin (), vals.end ());
}
template <typename ValueT, size_t CountV>
ValueT&
min (std::array<ValueT,CountV> &&) = delete;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Limiting functions // Limiting functions