Function make_clamped


#include <include/type_safe/bounded_type.hpp>

template <typename T, typename U1, typename U2>
constexpr auto make_clamped(T &&value, U1 &&lower, U2 &&upper) -> detail::make_bounded_type< clamping_verifier, true, true, T, U1, U2 >


Creates a [ts::clamped_type]() from the specified [ts::constraints::closed_interval]().

A [ts::clamped_type]() with the given value and lower and upper bounds, where the bounds are valid values. \notes If this function is passed in dynamic values of the same type as value, it will create a dynamic bound. Otherwise it must be passed static bounds.


Lines 529-540 in include/type_safe/bounded_type.hpp.

template <typename Value, typename T, typename LowerBound, typename UpperBound>
static constexpr auto verify(
    Value&& val, const constraints::closed_interval<T, LowerBound, UpperBound>& interval) ->
    typename std::decay<Value>::type
    return clamp(interval, std::forward<Value>(val));
An alias for [ts::constrained_type]() that uses [ts::constraints::closed_interval]() as its
`Constraint` and [ts::clamping_verifier]() as its `Verifier`. \notes This is some type where the
values are always clamped so that they are in a certain interval.

Add Discussion as Guest

Log in