| Home | Libraries | People | FAQ | More

## Function template clamp

boost::algorithm::clamp

## Synopsis

    // In header: <boost/algorithm/clamp.hpp>

    template<typename T, typename Pred>
      BOOST_CXX14_CONSTEXPR T const  &
      clamp(T const & val, typename boost::mpl::identity< T >::type const & lo,
            typename boost::mpl::identity< T >::type const & hi, Pred p);

## Description

Parameters: |
`hi` | The upper bound of the range to be clamped to
`lo` | The lower bound of the range to be clamped to
`p` | A predicate to use to compare the values. p ( a, b ) returns a boolean.
`val` | The value to be clamped
Returns: | the value "val" brought into the range [ lo, hi ] using the comparison predicate p. If p ( val, lo ) return lo. If p ( hi, val ) return hi. Otherwise, return the original value.