RUSH
Reusable Utilities in Single Headers is a collection of header-only utilities for C++
Loading...
Searching...
No Matches
algorithm.hpp
Go to the documentation of this file.
1
8#ifndef RUSH_ALGORITHM_HPP
9#define RUSH_ALGORITHM_HPP
10
11#include <algorithm>
12
13namespace rush {
14
28template <class T>
29constexpr const T &clamp(const T &v, const T &lo, const T &hi) {
30 return std::clamp(v, lo, hi);
31}
32
44template <class T>
45constexpr const T &clampl(const T &v, const T &lo) {
46 return (v < lo) ? lo : v;
47}
48
60template <class T>
61constexpr const T &clamph(const T &v, const T &hi) {
62 return (v > hi) ? hi : v;
63}
64
65} // namespace rush
66
67#endif // RUSH_ALGORITHM_HPP
constexpr const T & clamph(const T &v, const T &hi)
Clamps a value to be not greater than a specified upper bound.
Definition algorithm.hpp:61
constexpr const T & clampl(const T &v, const T &lo)
Clamps a value to be not less than a specified lower bound.
Definition algorithm.hpp:45
constexpr const T & clamp(const T &v, const T &lo, const T &hi)
Clamps a value within the inclusive range [lo, hi].
Definition algorithm.hpp:29