aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/core/utils
diff options
context:
space:
mode:
Diffstat (limited to 'arm_compute/core/utils')
-rw-r--r--arm_compute/core/utils/misc/Utility.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/arm_compute/core/utils/misc/Utility.h b/arm_compute/core/utils/misc/Utility.h
index 37c8b66e06..8dd9afd5cd 100644
--- a/arm_compute/core/utils/misc/Utility.h
+++ b/arm_compute/core/utils/misc/Utility.h
@@ -80,8 +80,10 @@ std::array<typename std::iterator_traits<Iterator>::value_type, N> make_array(It
*
* @return Clamped value.
*/
-template <typename T>
-inline T clamp(const T &n, const T &lower, const T &upper)
+template <typename DataType, typename RangeType = DataType>
+inline DataType clamp(const DataType &n,
+ const DataType &lower = std::numeric_limits<RangeType>::lowest(),
+ const DataType &upper = std::numeric_limits<RangeType>::max())
{
return std::max(lower, std::min(n, upper));
}