diff options
Diffstat (limited to 'include/mbgl/math/clamp.hpp')
-rw-r--r-- | include/mbgl/math/clamp.hpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/mbgl/math/clamp.hpp b/include/mbgl/math/clamp.hpp new file mode 100644 index 0000000000..38d430547d --- /dev/null +++ b/include/mbgl/math/clamp.hpp @@ -0,0 +1,14 @@ +#pragma once + +#include <mbgl/math/minmax.hpp> + +namespace mbgl { +namespace util { + +template <typename T> +T clamp(T value, T min_, T max_) { + return max(min_, min(max_, value)); +} + +} // namespace util +} // namespace mbgl |