Function sanitize_bounded

Synopsis

#include <include/type_safe/bounded_type.hpp>

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

Description

Creates a [ts::bounded_type]() to a specified [ts::constraints::closed_interval]().

Returns
A [ts::bounded_type]() with the given value and lower and upper bounds, where the bounds are valid values as well.
Exceptions

A - [ts::constrain_error]() if the value isn't valid, or anything else thrown by the constructor. \notes This is meant for sanitizing user input, using a recoverable error handling strategy. \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.

Source

Lines 417-425 in include/type_safe/bounded_type.hpp.

template <typename T, typename U1, typename U2>
constexpr auto make_bounded(T&& value, U1&& lower, U2&& upper)
    -> detail::make_bounded_type<assertion_verifier, true, true, T, U1, U2>
{
    using result_type = detail::make_bounded_type<assertion_verifier, true, true, T, U1, U2>;
    return result_type(std::forward<T>(value),
                       typename result_type::constraint_predicate(std::forward<U1>(lower),
                                                                  std::forward<U2>(upper)));
}





Add Discussion as Guest

Log in