coord/ops: add elementwise limit operation

This commit is contained in:
Danny Robson 2017-08-16 17:26:16 +10:00
parent d6b77f879f
commit c49738e7a3

View File

@ -703,6 +703,25 @@ namespace util {
}
//-------------------------------------------------------------------------
template <
size_t S,
typename T,
template<size_t,typename> class K,
typename = std::enable_if_t<
is_coord_v<K<S,T>>, void
>
>
constexpr
K<S,T>
limit (K<S,T> k, K<S,T> lo, K<S,T> hi)
{
assert (all (lo <= hi));
return max (min (k, hi), lo);
}
///------------------------------------------------------------------------
template <
size_t S,