diff options
Diffstat (limited to 'compat')
-rw-r--r-- | compat/util.hpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/compat/util.hpp b/compat/util.hpp index 33e64a80..453d94bd 100644 --- a/compat/util.hpp +++ b/compat/util.hpp @@ -46,6 +46,16 @@ public: inhibit_qt_signals(std::shared_ptr<QObject> val) : inhibit_qt_signals(*val.get()) {} }; +template<typename t, typename u, typename w> +auto clamp(t val, u min, w max) -> decltype (val * min * max) +{ + if (val > max) + return max; + if (val < min) + return min; + return val; +} + namespace detail { template<typename t> |