This library extends C++ std algorithm.
More...
#include <algorithm>
Go to the source code of this file.
|
template<class T > |
constexpr const T & | rush::clamp (const T &v, const T &lo, const T &hi) |
| Clamps a value within the inclusive range [lo, hi].
|
|
template<class T > |
constexpr const T & | rush::clampl (const T &v, const T &lo) |
| Clamps a value to be not less than a specified lower bound.
|
|
template<class T > |
constexpr const T & | rush::clamph (const T &v, const T &hi) |
| Clamps a value to be not greater than a specified upper bound.
|
|
This library extends C++ std algorithm.
- Author
- Raul Tapia (raultapia.com)
- Copyright
- GNU General Public License v3.0
- See also
- https://github.com/raultapia/rush
◆ clamp()
template<class T >
const T & rush::clamp |
( |
const T & | v, |
|
|
const T & | lo, |
|
|
const T & | hi ) |
|
constexpr |
Clamps a value within the inclusive range [lo, hi].
This function ensures that the value v
is within the range specified by lo
and hi
. If v
is less than lo
, it returns lo
. If v
is greater than hi
, it returns hi
. Otherwise, it returns v
.
- Template Parameters
-
T | The type of the value and the bounds. |
- Parameters
-
v | The value to clamp. |
lo | The lower bound of the range. |
hi | The upper bound of the range. |
- Returns
- constexpr const T& The clamped value.
◆ clamph()
template<class T >
const T & rush::clamph |
( |
const T & | v, |
|
|
const T & | hi ) |
|
constexpr |
Clamps a value to be not greater than a specified upper bound.
This function ensures that the value v
is not greater than the upper bound hi
. If v
is greater than hi
, it returns hi
. Otherwise, it returns v
.
- Template Parameters
-
T | The type of the value and the upper bound. |
- Parameters
-
v | The value to clamp. |
hi | The upper bound. |
- Returns
- constexpr const T& The clamped value.
◆ clampl()
template<class T >
const T & rush::clampl |
( |
const T & | v, |
|
|
const T & | lo ) |
|
constexpr |
Clamps a value to be not less than a specified lower bound.
This function ensures that the value v
is not less than the lower bound lo
. If v
is less than lo
, it returns lo
. Otherwise, it returns v
.
- Template Parameters
-
T | The type of the value and the lower bound. |
- Parameters
-
v | The value to clamp. |
lo | The lower bound. |
- Returns
- constexpr const T& The clamped value.
- Examples
- /github/workspace/include/rush/string.hpp.