clamp.h 278 B

123456789101112131415161718
  1. //
  2. // clamp.h
  3. // limit
  4. //
  5. // Created by Sam Jaffe on 12/9/23.
  6. //
  7. #pragma once
  8. #include <algorithm>
  9. #include <utility>
  10. namespace math {
  11. template <typename T>
  12. T const & clamp(T const & value, T const & min, T const & max) {
  13. return std::max(min, std::min(value, max));
  14. }
  15. }