Template Function rcppmath::clamp(const T&, const T&, const T&, Compare)
Defined in File clamp.hpp
Function Documentation
-
template<class T, class Compare>
constexpr const T &rcppmath::clamp(const T &v, const T &lo, const T &hi, Compare comp) Performs clamping with a provided Comparison object (comp).
Warning
Capturing the result of clamp by reference if one of the parameters is rvalue produces a dangling reference if that parameter is returned.
- Parameters:
v – [in] The value to clamp.
lo – [in] The lower boundary.
hi – [in] The higher boundary.
comp – [in] Comparison object that returns true if the first argument is less than the second.
- Returns:
Reference to lo if v is less than lo, reference to hi if hi is less than v, otherwise reference to v. “Less than” semantics determined by Comparison object.