maths: add array max/min convenience functions
This commit is contained in:
parent
90244c5347
commit
ced76721ac
28
maths.hpp
28
maths.hpp
@ -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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user