aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/Compat.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/Compat.h')
-rw-r--r--include/Compat.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/Compat.h b/include/Compat.h
index d69a9a2c1..b4a9437c2 100644
--- a/include/Compat.h
+++ b/include/Compat.h
@@ -14,6 +14,12 @@
namespace Sci {
+// std::clamp
+template <typename T>
+inline constexpr T clamp(T val, T minVal, T maxVal) {
+ return (val > maxVal) ? maxVal : ((val < minVal) ? minVal : val);
+}
+
// std::round (not present on older MacOSX SDKs)
template<class T>
T round(T arg) {