RUSH
Reusable Utilities in Single Headers is a collection of header-only utilities for C++
Toggle main menu visibility
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
13
namespace
rush {
14
28
template
<
class
T>
29
constexpr
const
T &
clamp
(
const
T &v,
const
T &lo,
const
T &hi) {
30
return
std::clamp(v, lo, hi);
31
}
32
44
template
<
class
T>
45
constexpr
const
T &
clampl
(
const
T &v,
const
T &lo) {
46
return
(v < lo) ? lo : v;
47
}
48
60
template
<
class
T>
61
constexpr
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
rush::clamph
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
rush::clampl
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
rush::clamp
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
include
rush
algorithm.hpp
Generated by
1.17.0