rcpputils  master
C++ API providing common utilities and data structures.
Namespaces | Functions
clamp.hpp File Reference

Restrict a value between two bounds. More...

#include <cassert>
Include dependency graph for clamp.hpp:

Go to the source code of this file.

Namespaces

 rcppmath
 

Functions

template<class T >
constexpr const T & rcppmath::clamp (const T &v, const T &lo, const T &hi)
 If v compares less than lo, returns lo; otherwise if hi compares less. More...
 
template<class T , class Compare >
constexpr const T & rcppmath::clamp (const T &v, const T &lo, const T &hi, Compare comp)
 Like the function above, but uses comp to compare the values. More...
 

Detailed Description

Restrict a value between two bounds.